GCJ built multithreaded program keeps creating zombies

Wolfgang Bangerth bangerth@ticam.utexas.edu
Wed Dec 18 16:09:00 GMT 2002


> Wolfgang> But in his code there is a Thread.join(), so if this does
> Wolfgang> something it probably calls waitpid(), no?
> 
> Nope, Thread.join is implemented in a platform-independent way.
> There are no calls to pthread_join in libgcj.

OK, I see, you set a mutex on exit of the new thread, and in join() you 
just wait to get it. Is this right?

Then on Linux you will create a zombie for every thread you create. I 
think one should either have the equivalent of waitpid() or pthread_join 
to release the zombies into the realm of the truly dead. Unfortunately, I 
can't find the place where you actually create a new thread right away...

The problem is more general then, though, as something likewise must 
happen on every OS: when you create a new thread or process, the OS 
reserves some space for the return value (an int for a process, a void* 
for a process), which it has to keep even after the death of the process 
or thread. If you don't ask the OS for this value (which you do with 
waitpid or pthread_join), the OS will not release this memory until the 
end of the spawning thread or process. If you create _many_ threads, this 
may become a problem also on systems other than Linux.

Regards
  Wolfgang

-------------------------------------------------------------------------
Wolfgang Bangerth              email:           bangerth@ticam.utexas.edu
                               www: http://www.ticam.utexas.edu/~bangerth




More information about the Gcc-bugs mailing list