|
From: Olivier B. <oli...@on...> - 2006-06-25 08:27:13
|
Hi everybody,
I am trying to debug a C++ library I developed that runs fine on some
computers and fails badly on others.
I use valgrind (valgrind-3.1.1 from gentoo) for that, but I have trouble
understanding some of its messages :
(extract of the output of '/usr/bin/valgrind -v ./testCeylanMostBasic
2>&1 |more' on a computer where the program does not crash)
==18442== Invalid write of size 4
==18442== at 0x40D2F2D: _GLOBAL__I__ZN6Ceylan3URI17ProtocolSeparatorE
(CeylanTypes.h:432)
==18442== by 0x40D30E4: (within
/home/sye/tmp-Ceylan-test-install/lib/libCeylan-0.3.so.0.0.3)
==18442== by 0x4052388: (within
/home/sye/tmp-Ceylan-test-install/lib/libCeylan-0.3.so.0.0.3)
==18442== by 0x400B70C: call_init (in /lib/ld-2.3.6.so)
==18442== by 0x400B7F1: _dl_init (in /lib/ld-2.3.6.so)
==18442== by 0x400081E: (within /lib/ld-2.3.6.so)
==18442== Address 0xBEFFCBA8 is not stack'd, malloc'd or (recently) free'd
==18442==
==18442== Invalid write of size 4
==18442== at 0x40D2E5A:
__static_initialization_and_destruction_0(int, int) (CeylanTypes.h:432)
==18442== by 0x40D2F46: _GLOBAL__I__ZN6Ceylan3URI17ProtocolSeparatorE
(CeylanTypes.h:432)
==18442== by 0x40D30E4: (within
/home/sye/tmp-Ceylan-test-install/lib/libCeylan-0.3.so.0.0.3)
==18442== by 0x4052388: (within
/home/sye/tmp-Ceylan-test-install/lib/libCeylan-0.3.so.0.0.3)
==18442== by 0x400B70C: call_init (in /lib/ld-2.3.6.so)
==18442== by 0x400B7F1: _dl_init (in /lib/ld-2.3.6.so)
==18442== by 0x400081E: (within /lib/ld-2.3.6.so)
==18442== Address 0xBEFFCB68 is not stack'd, malloc'd or (recently) free'd
--18442-- REDIR: 0x42CCBF0 (strlen) redirected to 0x401D4B0 (strlen)
--18442-- REDIR: 0x41BFF80 (operator new(unsigned)) redirected to
0x401B870 (operator new(unsigned))
(I can send the full valgrind log if it helps)
What puzzles me is that, as far as I know,
_GLOBAL__I__ZN6Ceylan3URI17ProtocolSeparatorE relates to "global
constructors keyed to Ceylan::URI::ProtocolSeparator" (after a double
c++filt), which is declared in CeylanUniformResourceIdentifier.h with
"""
namespace Ceylan
{
namespace URI
{
[..]
extern const std::string ProtocolSeparator ;
[..]
"""
and defined in CeylanUniformResourceIdentifier.cc
"""
const std::string Ceylan::URI::ProtocolSeparator = "://" ;
"""
Both are appropriate I think, and I ensured no other pre-main variable
refers to ProtocolSeparator.
Moreover, valgrind refers to "CeylanTypes.h:432" which is :
"""
typedef std::list<Ceylan::Uint16>::size_type ListSize ;
"""
(they do no seem related in any way, though)
Finally, whenever I wrap valgrind in a shell script (to give it the
exact same relevant options and redirect the output as on the command
line), it crashes my program with a segmentation fault.
Could anybody help me, notably with the interpretation of both "Invalid
write of size 4" ?
(if it helps :
- library and test executable have been built with g++-3.3.6 on
GNU/Linux with full warnings enabled and -g -ggdb -O0
- > ldd testCeylanMostBasic
linux-gate.so.1 => (0xffffe000)
libCeylan-0.3.so.0 =>
/home/sye/tmp-Ceylan-test-install/lib/libCeylan-0.3.so.0 (0xb7f00000)
libstdc++.so.5 =>
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.6/libstdc++.so.5 (0xb7e21000)
libgcc_s.so.1 =>
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.6/libgcc_s.so.1 (0xb7e19000)
libpthread.so.0 => /lib/libpthread.so.0 (0xb7dc7000)
libm.so.6 => /lib/libm.so.6 (0xb7da4000)
libc.so.6 => /lib/libc.so.6 (0xb7c8e000)
/lib/ld-linux.so.2 (0xb7feb000)
)
Thanks in advance for any hint,
regards,
Olivier.
|