Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uv_spawn probably blocks too many signals #5

Open
vtjnash opened this issue Dec 21, 2019 · 0 comments
Open

uv_spawn probably blocks too many signals #5

vtjnash opened this issue Dec 21, 2019 · 0 comments
Labels
help wanted Extra attention is needed

Comments

@vtjnash
Copy link
Sponsor Member

vtjnash commented Dec 21, 2019

We briefly block all signals during fork, because unix is often really bad at handling them during this call. However, we're blocking everything, and that's perhaps too much since it means buggy OS code (probably an atfork handler) can get us wedged. For example, I recorded us getting stuck here on my 10.14.6 laptop: Darwin Jameson.local 18.7.0 Darwin Kernel Version 18.7.0: Sun Dec 1 18:59:03 PST 2019; root:xnu-4903.278.19~1/RELEASE_X86_64 x86_64

(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
  * frame #0: 0x00007fff5f80a9e2 libdispatch.dylib`_firehose_task_buffer_init + 32
    frame #1: 0x00007fff5f7ea63d libdispatch.dylib`_dispatch_client_callout + 8
    frame #2: 0x00007fff5f7ebd4b libdispatch.dylib`_dispatch_once_callout + 20
    frame #3: 0x00007fff5f808b77 libdispatch.dylib`voucher_activity_get_metadata_buffer + 100
    frame #4: 0x00007fff5fa44163 libsystem_trace.dylib`_os_trace_init_slow + 94
    frame #5: 0x00007fff5f7ea63d libdispatch.dylib`_dispatch_client_callout + 8
    frame #6: 0x00007fff5f7ebd4b libdispatch.dylib`_dispatch_once_callout + 20
    frame #7: 0x00007fff5fa45f17 libsystem_trace.dylib`os_log_type_enabled + 463
    frame #8: 0x00007fff5deddf00 libnetwork.dylib`nw_path_close_fd + 144

We should probably avoid blocking anything that shouldn't be deferred (esp. SIGILL, SIGABRT, SIGSYS, SIGSEGV, SIGFPE, etc.) although nothing we do (except perhaps avoiding fork altogether by using vfork and/or posix_spawn+VFORK) is going to make this entirely reliable.

Note: prior to this, this had been spewing messages like the following during prior (successful) uv_spawn calls (many times, but it was an earlier process):

2019-12-21 00:01:51.006900-0500 julia-debug[17119:785417] nw_path_close_fd Failed to close guarded necp fd 43 [9: Bad file descriptor]

Hopefully this info helps someone on Google, since this appears to not be an uncommon issue for the past 2 years.

@vtjnash vtjnash added the help wanted Extra attention is needed label Dec 21, 2019
vtjnash pushed a commit that referenced this issue Jul 20, 2021
ERROR: LeakSanitizer: detected memory leaks

```
Direct leak of 432 byte(s) in 9 object(s) allocated from:
    #0 0x1062eedc2 in __sanitizer_mz_calloc+0x92 (libclang_rt.asan_osx_dynamic.dylib:x86_64+0x46dc2)
    #1 0x7fff20171eb6 in _malloc_zone_calloc+0x3a (libsystem_malloc.dylib:x86_64+0x1beb6)
    #2 0x7fff203ac180 in _CFRuntimeCreateInstance+0x124 (CoreFoundation:x86_64h+0x4180)
    #3 0x7fff203ab906 in __CFStringCreateImmutableFunnel3+0x84d (CoreFoundation:x86_64h+0x3906)
    #4 0x7fff203ab0a1 in CFStringCreateWithCString+0x48 (CoreFoundation:x86_64h+0x30a1)
    #5 0x1056f63e1 in uv__get_cpu_speed darwin.c:267
    #6 0x1056f491e in uv_cpu_info darwin.c:338
```

PR-URL: libuv#3098
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant