This repository has been archived by the owner on May 4, 2018. It is now read-only.
This repository has been archived by the owner on May 4, 2018. It is now read-only.
Open
Description
libuv master. This crash happens in OSX (in Linux it gets frozen). My code does the following:
-
- Run the following code:
uv_loop_t loop;
int err;
err = uv_loop_init(&loop);
if (err)
exit(1);
err = uv_run(&loop, UV_RUN_NOWAIT);
if (err)
exit(1);
err = uv_loop_close(&loop);
if (err)
exit(1);
-
- The typical double
fork()
to become a daemon.
- The typical double
-
- Init a new UV loop, init a uv_signal handler and call
uv_signal_start()
.
- Init a new UV loop, init a uv_signal handler and call
It crashes as shown below. It works perfectly if I don't fork.
lldb output in OSX:
(lldb) bt all
* thread #1: tid = 0x0000, 0x00007fff894fc866 libsystem_kernel.dylib`__pthread_kill + 10, stop reason = signal SIGSTOP
* frame #0: 0x00007fff894fc866 libsystem_kernel.dylib`__pthread_kill + 10
frame #1: 0x00007fff8687535c libsystem_pthread.dylib`pthread_kill + 92
frame #2: 0x00007fff854a3b1a libsystem_c.dylib`abort + 125
frame #3: 0x0000000101b52716 libuv.11.dylib`uv_signal_start [inlined] uv__signal_block_and_lock(saved_sigmask=0xffffffff00000000) + 182 at signal.c:106
frame #4: 0x0000000101b526b8 libuv.11.dylib`uv_signal_start(handle=0x00007ffa43404e10, signal_cb=0x0000000101ac01b0, signum=30) + 88 at signal.c:315
The UV code calling abort()
is in src/unix/signal.c line 106:
static void uv__signal_block_and_lock(sigset_t* saved_sigmask) {
sigset_t new_mask;
if (sigfillset(&new_mask))
abort();
if (pthread_sigmask(SIG_SETMASK, &new_mask, saved_sigmask))
abort();
if (uv__signal_lock())
abort(); // <----- HERE
}
So uv__signal_lock()
returns != 0:
static int uv__signal_lock(void) {
int r;
char data;
do {
r = read(uv__signal_lock_pipefd[0], &data, sizeof data);
} while (r < 0 && errno == EINTR);
return (r < 0) ? -1 : 0;
}
Can not I run (and close) a UV loop before forking and then run other after forking??
Metadata
Assignees
Labels
No labels