[Gc] BUG: Handle leak on windows with static threads

Lothar Scholz scholz at scriptolutions.com
Fri Feb 22 23:50:32 PST 2008


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