www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Garbage Collector Bug?

Hi all,

The following code:

<snip>
class C{
  public:
    void func(){
      x.length=0;
      x.length=100;
    }
  private:
    double[] x;
}

int main( ){
  C my_class = new C;

  for( int ii=0; ii<1000;  )
    my_class.func();
  return 0;
}
<snip>

Does not seem to me to have any "bug". It compiles correctly, and executes
silently.
However, using VALGRIND, the following error messages occour:

<snip>
==20985== Memcheck, a memory error detector.
==20985== Copyright (C) 2002-2005, and GNU GPL'd, by Julian Seward et al.
==20985== Using LibVEX rev 1313, a library for dynamic binary translation.
==20985== Copyright (C) 2004-2005, and GNU GPL'd, by OpenWorks LLP.
==20985== Using valgrind-3.0.1.SVN, a dynamic binary instrumentation framework.
==20985== Copyright (C) 2000-2005, and GNU GPL'd, by Julian Seward et al.
==20985== For more details, rerun with: -v
==20985==
==20985== Conditional jump or move depends on uninitialised value(s)
==20985==    at 0x8054766: _D3gcx3Gcx4markFPvPvZv (in /home/gasiba/bug)
==20985==    by 0x8054957: _D3gcx3Gcx11fullcollectFPvZk (in /home/gasiba/bug)
==20985==    by 0x8054819: _D3gcx3Gcx16fullcollectshellFZk (in /home/gasiba/bug)
==20985==    by 0x805394F: _D3gcx2GC12mallocNoSyncFkZPv (in /home/gasiba/bug)
==20985==    by 0x8053896: _D3gcx2GC6mallocFkZPv (in /home/gasiba/bug)
==20985==    by 0x8053A24: _D3gcx2GC6callocFkkZPv (in /home/gasiba/bug)
==20985==    by 0x8050028: _d_arraysetlength (in /home/gasiba/bug)
==20985==    by 0x804B575: _D3bug1C4funcFZv (in /home/gasiba/bug)
==20985==    by 0x804B5AA: _Dmain (in /home/gasiba/bug)
==20985==    by 0x804C31E: main (in /home/gasiba/bug)
==20985==
==20985== Conditional jump or move depends on uninitialised value(s)
==20985==    at 0x805433D: _D3gcx3Gcx8findPoolFPvZPS3gcx4Pool (in
/home/gasiba/bug)
==20985==    by 0x805476F: _D3gcx3Gcx4markFPvPvZv (in /home/gasiba/bug)
==20985==    by 0x8054957: _D3gcx3Gcx11fullcollectFPvZk (in /home/gasiba/bug)
==20985==    by 0x8054819: _D3gcx3Gcx16fullcollectshellFZk (in /home/gasiba/bug)
==20985==    by 0x805394F: _D3gcx2GC12mallocNoSyncFkZPv (in /home/gasiba/bug)
==20985==    by 0x8053896: _D3gcx2GC6mallocFkZPv (in /home/gasiba/bug)
==20985==    by 0x8053A24: _D3gcx2GC6callocFkkZPv (in /home/gasiba/bug)
==20985==    by 0x8050028: _d_arraysetlength (in /home/gasiba/bug)
==20985==    by 0x804B575: _D3bug1C4funcFZv (in /home/gasiba/bug)
==20985==    by 0x804B5AA: _Dmain (in /home/gasiba/bug)
==20985==    by 0x804C31E: main (in /home/gasiba/bug)
==20985==
==20985== Conditional jump or move depends on uninitialised value(s)
==20985==    at 0x8054342: _D3gcx3Gcx8findPoolFPvZPS3gcx4Pool (in
/home/gasiba/bug)
==20985==    by 0x805476F: _D3gcx3Gcx4markFPvPvZv (in /home/gasiba/bug)
==20985==    by 0x8054957: _D3gcx3Gcx11fullcollectFPvZk (in /home/gasiba/bug)
==20985==    by 0x8054819: _D3gcx3Gcx16fullcollectshellFZk (in /home/gasiba/bug)
==20985==    by 0x805394F: _D3gcx2GC12mallocNoSyncFkZPv (in /home/gasiba/bug)
==20985==    by 0x8053896: _D3gcx2GC6mallocFkZPv (in /home/gasiba/bug)
==20985==    by 0x8053A24: _D3gcx2GC6callocFkkZPv (in /home/gasiba/bug)
==20985==    by 0x8050028: _d_arraysetlength (in /home/gasiba/bug)
==20985==    by 0x804B575: _D3bug1C4funcFZv (in /home/gasiba/bug)
==20985==    by 0x804B5AA: _Dmain (in /home/gasiba/bug)
==20985==    by 0x804C31E: main (in /home/gasiba/bug)
==20985==
==20985== Use of uninitialised value of size 4
==20985==    at 0x8054783: _D3gcx3Gcx4markFPvPvZv (in /home/gasiba/bug)
==20985==    by 0x8054957: _D3gcx3Gcx11fullcollectFPvZk (in /home/gasiba/bug)
==20985==    by 0x8054819: _D3gcx3Gcx16fullcollectshellFZk (in /home/gasiba/bug)
==20985==    by 0x805394F: _D3gcx2GC12mallocNoSyncFkZPv (in /home/gasiba/bug)
==20985==    by 0x8053896: _D3gcx2GC6mallocFkZPv (in /home/gasiba/bug)
==20985==    by 0x8053A24: _D3gcx2GC6callocFkkZPv (in /home/gasiba/bug)
==20985==    by 0x8050028: _d_arraysetlength (in /home/gasiba/bug)
==20985==    by 0x804B575: _D3bug1C4funcFZv (in /home/gasiba/bug)
==20985==    by 0x804B5AA: _Dmain (in /home/gasiba/bug)
==20985==    by 0x804C31E: main (in /home/gasiba/bug)
==20985==
==20985== Use of uninitialised value of size 4
==20985==    at 0x80550F8: _D6gcbits6GCBits4testFkZk (in /home/gasiba/bug)
==20985==    by 0x80547B7: _D3gcx3Gcx4markFPvPvZv (in /home/gasiba/bug)
==20985==    by 0x8054957: _D3gcx3Gcx11fullcollectFPvZk (in /home/gasiba/bug)
==20985==    by 0x8054819: _D3gcx3Gcx16fullcollectshellFZk (in /home/gasiba/bug)
==20985==    by 0x805394F: _D3gcx2GC12mallocNoSyncFkZPv (in /home/gasiba/bug)
==20985==    by 0x8053896: _D3gcx2GC6mallocFkZPv (in /home/gasiba/bug)
==20985==    by 0x8053A24: _D3gcx2GC6callocFkkZPv (in /home/gasiba/bug)
==20985==    by 0x8050028: _d_arraysetlength (in /home/gasiba/bug)
==20985==    by 0x804B575: _D3bug1C4funcFZv (in /home/gasiba/bug)
==20985==    by 0x804B5AA: _Dmain (in /home/gasiba/bug)
==20985==    by 0x804C31E: main (in /home/gasiba/bug)
==20985==
==20985== Use of uninitialised value of size 4
==20985==    at 0x8055110: _D6gcbits6GCBits3setFkZv (in /home/gasiba/bug)
==20985==    by 0x80547C4: _D3gcx3Gcx4markFPvPvZv (in /home/gasiba/bug)
==20985==    by 0x8054957: _D3gcx3Gcx11fullcollectFPvZk (in /home/gasiba/bug)
==20985==    by 0x8054819: _D3gcx3Gcx16fullcollectshellFZk (in /home/gasiba/bug)
==20985==    by 0x805394F: _D3gcx2GC12mallocNoSyncFkZPv (in /home/gasiba/bug)
==20985==    by 0x8053896: _D3gcx2GC6mallocFkZPv (in /home/gasiba/bug)
==20985==    by 0x8053A24: _D3gcx2GC6callocFkkZPv (in /home/gasiba/bug)
==20985==    by 0x8050028: _d_arraysetlength (in /home/gasiba/bug)
==20985==    by 0x804B575: _D3bug1C4funcFZv (in /home/gasiba/bug)
==20985==    by 0x804B5AA: _Dmain (in /home/gasiba/bug)
==20985==    by 0x804C31E: main (in /home/gasiba/bug)
==20985==
==20985== Use of uninitialised value of size 4
==20985==    at 0x8055110: _D6gcbits6GCBits3setFkZv (in /home/gasiba/bug)
==20985==    by 0x80547CD: _D3gcx3Gcx4markFPvPvZv (in /home/gasiba/bug)
==20985==    by 0x8054957: _D3gcx3Gcx11fullcollectFPvZk (in /home/gasiba/bug)
==20985==    by 0x8054819: _D3gcx3Gcx16fullcollectshellFZk (in /home/gasiba/bug)
==20985==    by 0x805394F: _D3gcx2GC12mallocNoSyncFkZPv (in /home/gasiba/bug)
==20985==    by 0x8053896: _D3gcx2GC6mallocFkZPv (in /home/gasiba/bug)
==20985==    by 0x8053A24: _D3gcx2GC6callocFkkZPv (in /home/gasiba/bug)
==20985==    by 0x8050028: _d_arraysetlength (in /home/gasiba/bug)
==20985==    by 0x804B575: _D3bug1C4funcFZv (in /home/gasiba/bug)
==20985==    by 0x804B5AA: _Dmain (in /home/gasiba/bug)
==20985==    by 0x804C31E: main (in /home/gasiba/bug)
==20985==
==20985== ERROR SUMMARY: 842 errors from 7 contexts (suppressed: 24 from 5)
==20985== malloc/free: in use at exit: 33428 bytes in 12 blocks.
==20985== malloc/free: 12 allocs, 0 frees, 33428 bytes allocated.
==20985== For counts of detected errors, rerun with: -v
==20985== searching for pointers to 12 not-freed blocks.
==20985== checked 1192596 bytes.
==20985==
==20985== LEAK SUMMARY:
==20985==    definitely lost: 0 bytes in 0 blocks.
==20985==      possibly lost: 0 bytes in 0 blocks.
==20985==    still reachable: 33428 bytes in 12 blocks.
==20985==         suppressed: 0 bytes in 0 blocks.
==20985== Reachable blocks (those to which a pointer was found) are not shown.
==20985== To see them, rerun with: --show-reachable=yes
<snip>

These errors seem to come from the garbage collector...
Am I missing something?

Best Regards,
Tiago Gasiba
-- 
Tiago Gasiba (M.Sc.) - http://www.gasiba.de
Everything should be made as simple as possible, but not simpler.
Oct 28 2005