[Gc] RE: Handle leak on windows with static threads (fwd)

Hans Boehm Hans.Boehm at hp.com
Mon Feb 25 14:02:52 PST 2008


[This appears to not have made it out the first time:]

I think you are correct.  Thanks.

I checked in a somewhat more elaborate fix, since I think this problem also arose in some slightly different contexts.  I made available an updated snapshot at

http://www.hpl.hp.com/personal/Hans_Boehm/gc/gc_source/gc-7.1alpha3-080224.tar.gz

I believe all differences between the two snapshots are Windows-specific.

Hans

> -----Original Message-----
> From: Lothar Scholz [mailto:scholz at scriptolutions.com]
> Sent: Friday, February 22, 2008 11:51 PM
> To: Boehm, Hans
> Cc: gc@
> Subject: BUG: Handle leak on windows with static threads
>
> Hello,
>
> i don't understand to much from the GC so maybe i did something wrong.
> I used the NT_STATIC_THREADS_MAKEFILE and the
>
> GC_beginthreadex();
> GC_endthreadex(0);
>
> functions to start create a thread and end the thread.
>
> I found that there is exactly one thread handle not closed
> for each thread. So after looking many times through my own
> code and reading the gc.h. I started to believe that there is
> a problem in the GC.
>
> If i add a line to function GC_delete_thread in win32_threads.c.
>
> void GC_delete_thread(DWORD id)
> {
>   if (GC_win32_dll_threads) {
>     GC_thread t = GC_lookup_thread_inner(id);
>
>     if (0 == t) {
>       WARN("Removing nonexistent thread %ld\n", (GC_word)id);
>     } else {
>       GC_delete_gc_thread(t);
>     }
>   } else {
>  >>>>>>>>>>>>>>>>>>>>>>> I added this
>   { GC_thread t = GC_lookup_thread_inner(id); if (t)
> CloseHandle(t -> handle); }
>     <<<<<<<<<<<<<<<<<<<<<<<<<<
>   }
>
> then the memory leak is fixed. Maybe you can look at it and
> tell me if this is a correct problem analysis. I don't
> understand too much about the internals but i looked many
> times and couldn't find the place of another CloseHandle
> location for (!GC_win32_dll_threads).
>
>
> --
> Best regards,
>  Lothar Scholz              mailto:scholz at scriptolutions.com
>
>


More information about the Gc mailing list