Re: using of fork() in multithreaded application

Valery Ushakov <[email protected]>
Newsgroups gmane.os.netbsd.devel.kernel
Message-ID <[email protected]>
On Fri, Jan 24, 2025 at 14:38:22 +0100, Jörg Sonnenberger wrote:

> On 1/24/25 1:27 PM, Greg Troxel wrote:
[...]
> > In 2010ish I saw a hard-to-find bug, the details of which are now fading
> > from memory.  I think it was some kind of lock taken in a routine that
> > was called after fork and before exec.  I think the program was python
> > and the lock was in libc's malloc. (This would have NetBSD 5 or 6.)
> 
> I've fixed various issues in libc to make fork-without-exec reasonable
> reliable for many use cases. malloc certainly was one of them.

That reminds me... (sorry if hijacking the thread).

When a user-supplied malloc is used (dmalloc &c, or program's own
malloc like e.g. in inferno-os), they do not override jemalloc fork
hooks as that's not part of malloc "API contract" so to say.  jemalloc
hooks are run on fork with unitialized jemalloc internals.

What is the right corse of action here?

-uwe
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.