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 bonefish)

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 miqlas, 8 years ago

Attachment: fish_debug_1.png added

Debugger-1

by miqlas, 8 years ago

Attachment: fish_debug_2.png added

Debugger-2

comment:1 by korli, 8 years ago

Component: - GeneralSystem/POSIX

comment:2 by korli, 8 years ago

Owner: changed from nobody to axeld
Status: newassigned

Axel might have a clue.

comment:3 by bonefish, 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.

Note: See TracTickets for help on using tickets.