second-state / ssvm-napi

SSVM Node.js Addon
Apache License 2.0
13 stars 3 forks source link

Node.js crashes at CTRL-C #37

Closed juntao closed 4 years ago

juntao commented 4 years ago

When I press CTRL-C to quit a node.js server when running SSVM, it crashes with the following message.

FATAL [default] CRASH HANDLED; Application has crashed due to [SIGINT] signal
    ======= Backtrace: =========
    [1]  0x65ad8) [0x7fa989a3ead8]:_modules/ssvm/lib/binding/linux-x64/ssvm.node(+0x65ad8) [0x7fa989a3ead8]
    [2]  0x46470) [0x7fa98c3f6470]:_64-linux-gnu/libc.so.6(+0x46470) [0x7fa98c3f6470]
    [3]  0x76) [0x7fa98c4d2416]:_64-linux-gnu/libc.so.6(epoll_pwait+0x76) [0x7fa98c4d2416]
    [4] node() [0xa80f1f]
    [5]  0x14b) [0xa7012b]:_run+0x14b) [0xa7012b]
    [6]  0x565) [0x9045b5]:_ZN4node5StartEPN2v87IsolateEPNS_11IsolateDataERKSt6vectorISsSaISsEES9_+0x565) [0x9045b5]
    [7]  0x48f) [0x90282f]:_ZN4node5StartEiPPc+0x48f) [0x90282f]
    [8]  0xf3) [0x7fa98c3d71e3]:_64-linux-gnu/libc.so.6(__libc_start_main+0xf3) [0x7fa98c3d71e3]
    [9] node() [0x8bbe95]

2020-07-29 00:12:46,638 WARNING [default] Aborting application. Reason: Fatal log at [../ssvm-core/thirdparty/easyloggingpp/easylogging++.cc:2876]
Aborted
hydai commented 4 years ago

CTRL-C will send a SIGINT signal to the running process. You can send CTRL-C to a clean node.js server without SSVM, and you will find that the return value is 130 (SIGINT).

SSVM provides its own signal handling system to take over the system signal. When you send the CTRL-C, SSVM catches it first, then terminates itself, and report Aborted.

If we don't want this error, we could disable the custom signal handler in SSVM. Please notice that all of the signals will not be handled by SSVM anymore after we disable this feature.

juntao commented 4 years ago

Hmm, I did not see this error in previous versions of the SSVM. I think the "right" behavior is to trap the signal and print "terminated by the user" on the console. Thanks.

hydai commented 4 years ago

We didn't change any API related with the signal handler.

It seems like you use CTRL-C to terminate the SSVM process not the node.js process? For example, if you run kmeans which takes so much time and you try to terminate it when SSVM is still running, then you will get this error message.

I think print terminated by the user on the console is okay. Or we can make it silent just like node.js does, users send CTRL-C and it just terminated. Which one is better?

juntao commented 4 years ago

Let's do silent exit then. Thanks

hydai commented 4 years ago

Got it. Will be done in the next release.