Re: using of fork() in multithreaded application
Jörg Sonnenberger <[email protected]>
| Newsgroups | gmane.os.netbsd.devel.kernel |
|---|---|
| Message-ID | <[email protected]> |
On 1/24/25 4:10 PM, Taylor R Campbell wrote: >> Date: Fri, 24 Jan 2025 16:45:29 +0300 >> From: Valery Ushakov <[email protected]> >> >> 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? > > The right course of action is to define the symbols: > > _malloc_prefork > _malloc_postfork > _malloc_postfork_child > > These zero-argument functions are invoked at the obvious times in > libc's fork() function. There's an example in src/lib/libbsdmalloc. ..and of course making sure that all parts of the malloc interface are implemented. posix_memalign is often missing in custom overrides as well. Joerg