[Gc] Valgrind/g++: assertion failure in GC_mark_from()?

Marnix Klooster marnix.klooster at gmail.com
Fri May 5 04:49:28 PDT 2006


Hi all,

I just started to play around with the gc library, taking a large legacy
application and replacing our own custom allocator by GC_MALLOC() and friends.
No complaints so far.

Then I wanted to see how the memory usage improved, so I ran valgrind on the
new binaries.  I got strange core dumps.  So I tried small examples.  Those
work fine, except that they dump core when running under valgrind.

Here is the simplest possible example:

    #include "gc.h"

    int main() {
            GC_MALLOC(42);
    }

Compile and run this using the C++ compiler (C works fine):

    g++ -c -o t.o t.cc
    g++ -lgc -o t t.o
    valgrind --tool=memcheck --num-callers=100 ./t

The output is attached (this was generated on Gentoo using gcc 3.3.6 ("Gentoo
3.3.6, ssp-3.3.6-1.0, pie-8.7.8") and dev-libs/boehm-gc-6.5).

I've tested this only with valgrind 2.4.0 on Linux+gcc thus far (different gcc
versions: 3.3.6 on Gentoo, 3.3.3 on SuSE 9), with different versions of gc
(I've tested at least 6.5, 6.6, and 6.7).

(Note that in this example, and in all small examples that I could come up
with, the generated binary works fine, without dumping core.)

Another piece of information: when testing this with a gc6.7 library with
assertions on, I get this from valgrind (not when running stand-alone):

    Assertion failure: mark.c:654
    assertion failure

This is in GC_mark_from():

          GC_ASSERT(descr < (word)GC_greatest_plausible_heap_addr
                            - (word)GC_least_plausible_heap_addr);

>From several places I gather that valgrind and gc should be working fine
together; what am I doing wrong?

Thanks.

Groetjes,
 <><
Marnix
--
Marnix Klooster
marnix.klooster at gmail.com
-------------- next part --------------
==4963== Memcheck, a memory error detector for x86-linux.
==4963== Copyright (C) 2002-2005, and GNU GPL'd, by Julian Seward et al.
==4963== Using valgrind-2.4.0, a program supervision framework for x86-linux.
==4963== Copyright (C) 2000-2005, and GNU GPL'd, by Julian Seward et al.
==4963== For more details, rerun with: -v
==4963== 
==4963== Conditional jump or move depends on uninitialised value(s)
==4963==    at 0x1B935D54: GC_push_all_eager (in /usr/lib/libgc.so.1.0.2)
==4963== 
==4963== Conditional jump or move depends on uninitialised value(s)
==4963==    at 0x1B935D5A: GC_push_all_eager (in /usr/lib/libgc.so.1.0.2)
==4963== 
==4963== Use of uninitialised value of size 4
==4963==    at 0x1B935BD9: GC_mark_and_push_stack (in /usr/lib/libgc.so.1.0.2)
==4963== 
==4963== Use of uninitialised value of size 4
==4963==    at 0x1B935BEA: GC_mark_and_push_stack (in /usr/lib/libgc.so.1.0.2)
==4963== 
==4963== Use of uninitialised value of size 4
==4963==    at 0x1B92FDEB: GC_add_to_black_list_stack (in /usr/lib/libgc.so.1.0.2)
==4963== 
==4963== Use of uninitialised value of size 4
==4963==    at 0x1B92FE01: GC_add_to_black_list_stack (in /usr/lib/libgc.so.1.0.2)
==4963== 
==4963== Use of uninitialised value of size 4
==4963==    at 0x1B92FE3A: GC_add_to_black_list_stack (in /usr/lib/libgc.so.1.0.2)
==4963== 
==4963== Conditional jump or move depends on uninitialised value(s)
==4963==    at 0x1B934F81: GC_mark_from (in /usr/lib/libgc.so.1.0.2)
==4963==    by 0xFFFFFFFE: ???
==4963== 
==4963== Conditional jump or move depends on uninitialised value(s)
==4963==    at 0x1B934FCD: GC_mark_from (in /usr/lib/libgc.so.1.0.2)
==4963==    by 0xFFFFFFFE: ???
==4963== 
==4963== Conditional jump or move depends on uninitialised value(s)
==4963==    at 0x1B934FD7: GC_mark_from (in /usr/lib/libgc.so.1.0.2)
==4963==    by 0xFFFFFFFE: ???
==4963== 
==4963== Use of uninitialised value of size 4
==4963==    at 0x1B934FF0: GC_mark_from (in /usr/lib/libgc.so.1.0.2)
==4963== 
==4963== Conditional jump or move depends on uninitialised value(s)
==4963==    at 0x1B934FF3: GC_mark_from (in /usr/lib/libgc.so.1.0.2)
==4963== 
==4963== Use of uninitialised value of size 4
==4963==    at 0x1B935004: GC_mark_from (in /usr/lib/libgc.so.1.0.2)
==4963== 
==4963== Use of uninitialised value of size 4
==4963==    at 0x1B93501A: GC_mark_from (in /usr/lib/libgc.so.1.0.2)
==4963== 
==4963== Use of uninitialised value of size 4
==4963==    at 0x1B935047: GC_mark_from (in /usr/lib/libgc.so.1.0.2)
==4963== 
==4963== Conditional jump or move depends on uninitialised value(s)
==4963==    at 0x1B934FCD: GC_mark_from (in /usr/lib/libgc.so.1.0.2)
==4963== 
==4963== Conditional jump or move depends on uninitialised value(s)
==4963==    at 0x1B934FD7: GC_mark_from (in /usr/lib/libgc.so.1.0.2)
==4963== 
==4963== Invalid read of size 4
==4963==    at 0x1B934F74: GC_mark_from (in /usr/lib/libgc.so.1.0.2)
==4963==    by 0xFFFFFFFE: ???
==4963==  Address 0x52C000C0 is not stack'd, malloc'd or (recently) free'd
==4963== 
==4963== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==4963==  Bad permissions for mapped region at address 0x52C000C0
==4963==    at 0x1B934F74: GC_mark_from (in /usr/lib/libgc.so.1.0.2)
==4963==    by 0xFFFFFFFE: ???
==4963== 
==4963== ERROR SUMMARY: 244 errors from 18 contexts (suppressed: 23 from 1)
==4963== malloc/free: in use at exit: 0 bytes in 0 blocks.
==4963== malloc/free: 0 allocs, 0 frees, 0 bytes allocated.
==4963== For counts of detected errors, rerun with: -v
==4963== No malloc'd blocks -- no leaks are possible.
make: *** [run-valgrind] Segmentation fault







More information about the Gc mailing list