Changes between Initial Version and Version 3 of Ticket #13111


Ignore:
Timestamp:
Dec 14, 2016, 8:25:59 PM (7 years ago)
Author:
bonefish
Comment:

Our malloc() implementation is actually async signal safe, by way of deferring signal delivery. I suspect the issue in this case is rather that malloc() isn't fork() safe in an multi-threaded program. If one thread calls fork() while another is currently in malloc() (or free(),...) the child process will inherit a locked mutex.

The solution is to register respective atfork() hooks for the memory allocator. They would acquire the mutex pre-fork() and release it post-fork(), thus ensuring that the child finds the memory allocator in a usable state.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #13111

    • Property Component - GeneralSystem/POSIX
    • Property Owner changed from nobody to axeld
    • Property Status newassigned
  • Ticket #13111 – Description

    initial v3  
    66
    77
    8 {{{
    9 krader is right that execve is allocating memory, and I would tentatively argue that this is a bug in Haiku. In particular POSIX requires that execve is async-signal safe, which means it may be called from a signal handler, and thus must not call malloc internally.
    10 }}}
     8
     9  krader is right that execve is allocating memory, and I would tentatively argue that this is a bug in Haiku. In particular POSIX requires that execve is async-signal safe, which means it may be called from a signal handler, and thus must not call malloc internally.
    1110
    1211Original bugreport, for the history: