Gregory P. Smith added the comment:

Another alternative *might* be to check if the lock is locked (non-blocking 
acquire?) and release it if so. Under the normal assumption that we are the 
only thread running immediately post-fork().

I'm not sure that can be guaranteed reliable given that other C code could've 
used pthread_atfork to register an "after" fork handler that spawns threads.  
But that should be rare, and nothing here can really fix the underlying 
"programmer has mixed fork and threads" issue. Only ameliorate it.

But i'm not sure this post fork memory leak is really a problem other than 
potentially showing up in memory sanatizer runs involving forked children.  The 
scenario where it would be an actual leak is if a process does serial fork() 
calls with the parent(s) dying rather than forking new children from a common 
parent.  That would grow the leak as each child would have an additional lock 
allocated (a few bytes).  I don't _believe_ that kind of process pattern is 
common (but people do everything).

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue30395>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to