rstudio / httpuv

HTTP and WebSocket server package for R
Other
229 stars 86 forks source link

Calling stopAllServers() can result in crash #116

Closed wch closed 6 years ago

wch commented 6 years ago
R -d lldb
run --quiet
library(httpuv)
startServer("0.0.0.0", 5001, list(call = function(req) {}))
startServer("0.0.0.0", 5001, list(call = function(req) {}))
stopAllServers()

Result:

$ R -d lldb
*** Further command line arguments ('--no-save --no-restore-data --quiet ') disregarded
*** (maybe use 'run --no-save --no-restore-data --quiet ' from *inside* lldb)

(lldb) target create "/Library/Frameworks/R.framework/Resources/bin/exec/R"
Current executable set to '/Library/Frameworks/R.framework/Resources/bin/exec/R' (x86_64).
(lldb) run --quiet
Process 40059 launched: '/Library/Frameworks/R.framework/Resources/bin/exec/R' (x86_64)
> library(httpuv)
> startServer("0.0.0.0", 5001, list(call = function(req) {}))
[1] "4330444536"
> startServer("0.0.0.0", 5001, list(call = function(req) {}))
Error in startServer("0.0.0.0", 5001, list(call = function(req) { : 
  Failed to create server
> stopAllServers()
Assertion failed: (0), function uv_close, file src/unix/core.c, line 182.
Process 40059 stopped
* thread #2, stop reason = signal SIGABRT
    frame #0: 0x00007fff566e6e3e libsystem_kernel.dylib`__pthread_kill + 10
libsystem_kernel.dylib`__pthread_kill:
->  0x7fff566e6e3e <+10>: jae    0x7fff566e6e48            ; <+20>
    0x7fff566e6e40 <+12>: movq   %rax, %rdi
    0x7fff566e6e43 <+15>: jmp    0x7fff566de0b8            ; cerror_nocancel
    0x7fff566e6e48 <+20>: retq   
Target 0: (R) stopped.
(lldb) bt
* thread #2, stop reason = signal SIGABRT
  * frame #0: 0x00007fff566e6e3e libsystem_kernel.dylib`__pthread_kill + 10
    frame #1: 0x00007fff56825150 libsystem_pthread.dylib`pthread_kill + 333
    frame #2: 0x00007fff56643312 libsystem_c.dylib`abort + 127
    frame #3: 0x00007fff5660b368 libsystem_c.dylib`__assert_rtn + 320
    frame #4: 0x0000000107e7c492 httpuv.so`uv_close + 434
    frame #5: 0x0000000107e3ed70 httpuv.so`close_handle_cb(uv_handle_s*, void*) + 32
    frame #6: 0x0000000107e7abb0 httpuv.so`uv_walk + 368
    frame #7: 0x0000000107e3f0f6 httpuv.so`io_thread(void*) + 438
    frame #8: 0x00007fff568226c1 libsystem_pthread.dylib`_pthread_body + 340
    frame #9: 0x00007fff5682256d libsystem_pthread.dylib`_pthread_start + 377
    frame #10: 0x00007fff56821c5d libsystem_pthread.dylib`thread_start + 13