[Gc] Re: Does thread support work for the windows 7.0 version?

Achilleas Margaritis axilmar at otenet.gr
Sat Dec 15 17:43:27 PST 2007


Here is the output of testgc.exe:

Completed 3 tests
Allocated 1715870 collectable objects
Allocated 303 uncollectable objects
Allocated 3750000 atomic objects
Allocated 34440 stubborn objects
Finalized 6602/6603 objects - finalization is probably ok
Total number of bytes allocated is 377021456
Final heap size is 13774848 bytes
Collector appears to work

I tried to run testgc.exe from within the Visual Studio IDE but I get 
the same crashes as in my program...so most probably I am doing 
something wrong.

I removed GC_DEBUG from the preprocessor options and testgc.exe runs 
fine from within Visual Studio.

I tried the same thing (i.e. removing GC_DEBUG) with my project, but it 
does not work, I still get the crashes.

After lots of trying, I found it! the problem is with STL: declaring an 
std::list object makes the collector to crash.

Here is a simple program:

#include <windows.h>
#include <gc.h>
#include <stdio.h>
#include <list>

std::list<int> data;

int rnd(int i) {
     return rand() % i;
}

DWORD WINAPI thread_proc(LPVOID param) {
     for(int i = 0; i < 100000; ++i) {
         void *mem = GC_malloc(rnd(10) + 1000);
     }
     return 0;
}

int main() {
     GC_INIT();
     GC_CreateThread(NULL, 0, thread_proc, 0, 0, 0);
     getchar();
     return 0;
}

The above program crashes. If I remove the std::list, the program runs fine.

O/H Hans Boehm έγραψε:
> I haven't had time to run the code.  As far as I know, it should work,
> though there may be an issue with the way the collector was built.
> Can you run gctest.exe with the same library version?  I didn't
> immediately notice your code doing anything that gctest does not do.
> 
> Hans
> 
> On Sat, 15 Dec 2007, Achilleas Margaritis wrote:
> 
>> Dear mr Hans Boehm,
>>
>> I have posted my problem with the gc a few days ago but I still do not
>> have a reply from you about it.
>>
>> Should I wait for your reply? is it something I am doing wrong in my
>> code? should I use another version of the gc? does thread support work
>> for the 7.0 version of the collector?
>>
>> I would be grateful if you can respond to this in the next few days,
>> because I have a customer waiting for a reply from me on a project that
>> its feasibility depends on the gc (your gc, there are no other
>> collectors for c++).
>>
>> Best regards
>>
>> Achilleas Margaritis
>>
>> _______________________________________________
>> Gc mailing list
>> Gc at linux.hpl.hp.com
>> http://www.hpl.hp.com/hosted/linux/mail-archives/gc/
>>



More information about the Gc mailing list