|
From: Michael L. <in...@pa...> - 2003-06-19 04:57:41
|
Please assist in explaining this output. It regards a class varaiable=20
declared
=09static MyApp*=09_ptr;
and defined with
=09MyApp* MyApp::_ptr;
It is being initialized and released with:
=09static MyApp& GetRef()
=09{=09
=09=09if( 0 =3D=3D _ptr )
=09=09=09_ptr =3D new MyApp;
=09=09return *_ptr;
=09}
=09static void shutdown()
=09{=20
=09=09delete _ptr;=20
=09=09_ptr =3D 0;
=09}
valgrind output:
=3D=3D10037=3D=3D Invalid write of size 4
=3D=3D10037=3D=3D at 0x408F3E14: _GLOBAL__I__ZN12MyApp4_ptrE=20
(/usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.2/include/g++-v3/bits/stl_set.h:1=
02)
=3D=3D10037=3D=3D by 0x408F72B4: (within=20
/home/mel/Projects/src/.libs/libmyapp.so.0.0.0)
=3D=3D10037=3D=3D by 0x408C4110: (within=20
/home/mel/Projects/src/.libs/libmyapp.so.0.0.0)
=3D=3D10037=3D=3D by 0x4000AD4B: call_init (in /lib/ld-2.3.1.so)
=3D=3D10037=3D=3D Address 0xBFFFE1C4 is not stack'd, malloc'd or free'=
d
=3D
What is the problem with this? Thank you.
-- Michael
|
|
From: Bryan O'S. <bo...@se...> - 2003-06-19 05:55:39
|
On Wed, 2003-06-18 at 21:57, Michael Labhard wrote: > What is the problem with this? Thank you. Beats me. Looks like you're not compiling with g++, as I don't recognise the name mangling scheme for _GLOBAL__I__ZN12MyApp4_ptrE. Are you using the Intel compiler? Perhaps it's generating bad code. <b |
|
From: Michael L. <in...@pa...> - 2003-06-19 14:18:30
|
> Beats me. Looks like you're not compiling with g++, as I don't
> recognise the name mangling scheme for _GLOBAL__I__ZN12MyApp4_ptrE. Ar=
e
> you using the Intel compiler? Perhaps it's generating bad code.
Here is the compile environment:
Linux 2.4.21 #1 SMP i686 AMD Athlon(tm) MP 2200+ AuthenticAMD GNU/Linux
gcc (GCC) 3.2.2 glibc-2.3.1-r4
AM_CXXFLAGS=09=3D -march=3Dathlon-mp -g -O -Wall -pipe -pthread=09\
=09-fstack-check =09=09=09=09=09=09\
=09-I@top_srcdir@/src/include =09=09=09\
=09-I@top_srcdir@/gui/plot=09=09=09=09\
=09-I/usr/include/postgresql/server=09\
=09-I${QTDIR}/include=09=09=09=09=09\
=09-DQT_THREAD_SUPPORT=09=09=09=09=09\
=09-D_GNU_SOURCE=09=09=09=09=09=09
|
|
From: Nicholas N. <nj...@ca...> - 2003-06-19 08:08:14
|
On Wed, 18 Jun 2003, Michael Labhard wrote: > ==10037== Invalid write of size 4 > ==10037== at 0x408F3E14: _GLOBAL__I__ZN12MyApp4_ptrE > (/usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.2/include/g++-v3/bits/stl_set.h:102) > ==10037== by 0x408F72B4: (within > /home/mel/Projects/src/.libs/libmyapp.so.0.0.0) > ==10037== by 0x408C4110: (within > /home/mel/Projects/src/.libs/libmyapp.so.0.0.0) > ==10037== by 0x4000AD4B: call_init (in /lib/ld-2.3.1.so) > ==10037== Address 0xBFFFE1C4 is not stack'd, malloc'd or free'd _GLOBAL__I__ZN12MyApp4_ptrE is not in your code, so there's a good(?) chance it's not your fault. Valgrind says "Address 0xBFFFE1C4 is not stack'd, malloc'd or free'd" but 0xBFFFE1C4 looks like a stack address, maybe that code is writing just beneath the stack pointer. You could try the --workaround-gcc296-bugs=yes option which skips that check. You could also try to reduce the program to a small example and see if it still happens; if so you can probably be more confident that it's not your fault, in which case suppressing it would be appropriate. N |