Opened 8 years ago
Last modified 8 years ago
#13111 closed bug
Possible execve bug in Haiku — at Version 3
Reported by: | miqlas | Owned by: | axeld |
---|---|---|---|
Priority: | normal | Milestone: | Unscheduled |
Component: | System/POSIX | Version: | R1/Development |
Keywords: | Cc: | ||
Blocked By: | Blocking: | ||
Platform: | All |
Description (last modified by )
Noticed it in fish shell, below the bugreport:
https://github.com/fish-shell/fish-shell/issues/3645
Komment from ridiculousfish:
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.
Original bugreport, for the history:
Reproduction steps
write characters into your Terminal press Ctrl-C Repeat .... Profit! Fish hangs after Ctrl-C and aren't accept any input anymore, so you need to kill it. I never had any problems like this with the 2.3.x releases. (if i remember correctly.)
Change History (5)
by , 8 years ago
Attachment: | fish_debug_1.png added |
---|
comment:1 by , 8 years ago
Component: | - General → System/POSIX |
---|
comment:3 by , 8 years ago
Description: | modified (diff) |
---|
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.
Debugger-1