Re: using of fork() in multithreaded application

Greg Troxel <[email protected]>
Newsgroups gmane.os.netbsd.devel.kernel
Message-ID <[email protected]>
Jörg Sonnenberger <[email protected]> writes:

> On 1/24/25 1:27 PM, Greg Troxel wrote:
>> Taylor R Campbell <[email protected]> writes:
>> 
>>>> Date: Wed, 22 Jan 2025 16:47:13 +0100
>>>> From: Peter Skvarka <[email protected]>
>>>>
>>>> I have two questions:
>>>> Is safe using of fork() in NetBSD 10.1 in mutlithreaded application ?
>>>
>>> Generally yes, with the caveat that it is difficult for applications
>>> to use correctly.
>> 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's great to hear.  Certainly it's nicer if our system is more likely
to work when faced with out-of-spec behavior but it's still wrong of
programs to use malloc after fork and before exec.
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.