SAP / node-rfc

Asynchronous, non-blocking SAP NW RFC SDK bindings for Node.js
Apache License 2.0
251 stars 73 forks source link

stack traces for potential segfaults? #138

Closed clausreinke closed 4 years ago

clausreinke commented 4 years ago

While testing out proposed fixes for #128, our servers occasionally disappear (to be restarted by their services). When that happens, there is no error information whatsoever.

This reminds me a lot of segfaults, so I checked the node docs for event handling options. Those explain that attaching JS event handlers to such events would make no sense and that source debug info would be required from the native code in question to get useful stack traces anyway.

So I wonder: would it be possible to add an optional segfault handler and debug info in this packages native code in the hope of gaining helpful stack traces (or a confirmation that the silent crashes are either not segfaults or not located in this package or its dependencies)?

clausreinke commented 4 years ago

just learned about Diagnostic Report (already in v12, too, as experimental). It seems the debug info for useful native stack traces is already there, though I still don't know how to trigger a report on a fatal error (--report-on-fatalerror did not seem to do the trick on the single crash I managed all day).

Here is a native stack triggered in the error handler of a client.invoke (note the PrepareAsync::OnOK with source file and line number):

  "nativeStack": [
    {
      "pc": "0x00007ff71adf1729",
      "symbol": "std::basic_ostream >::operator<<+10873"
    },
    {
      "pc": "0x00007ff71adf5b4c",
      "symbol": "std::basic_ostream >::operator<<+28316"
    },
    {
      "pc": "0x00007ff71adf4b08",
      "symbol": "std::basic_ostream >::operator<<+24152"
    },
    {
      "pc": "0x00007ff71adedfb6",
      "symbol": "std::basic_ostream >::basic_ostream >+5638"
    },
    {
      "pc": "0x00007ff71b69c4e0",
      "symbol": "v8::internal::Builtins::builtin_handle+325536"
    },
    {
      "pc": "0x00007ff71b69ba27",
      "symbol": "v8::internal::Builtins::builtin_handle+322791"
    },
    {
      "pc": "0x00007ff71b69bd68",
      "symbol": "v8::internal::Builtins::builtin_handle+323624"
    },
    {
      "pc": "0x00007ff71b69bb6e",
      "symbol": "v8::internal::Builtins::builtin_handle+323118"
    },
    {
      "pc": "0x00007ff71bb1414d",
      "symbol": "v8::internal::SetupIsolateDelegate::SetupHeap+568205"
    },
    {
      "pc": "0x00007ff71ba93bdc",
      "symbol": "v8::internal::SetupIsolateDelegate::SetupHeap+42524"
    },
    {
      "pc": "0x00007ff71ba93bdc",
      "symbol": "v8::internal::SetupIsolateDelegate::SetupHeap+42524"
    },
    {
      "pc": "0x00007ff71ba93bdc",
      "symbol": "v8::internal::SetupIsolateDelegate::SetupHeap+42524"
    },
    {
      "pc": "0x00007ff71ba93bdc",
      "symbol": "v8::internal::SetupIsolateDelegate::SetupHeap+42524"
    },
    {
      "pc": "0x00007ff71ba93bdc",
      "symbol": "v8::internal::SetupIsolateDelegate::SetupHeap+42524"
    },
    {
      "pc": "0x00007ff71bae1a06",
      "symbol": "v8::internal::SetupIsolateDelegate::SetupHeap+361542"
    },
    {
      "pc": "0x00007ff71ba8f313",
      "symbol": "v8::internal::SetupIsolateDelegate::SetupHeap+23891"
    },
    {
      "pc": "0x00007ff71bb74e70",
      "symbol": "v8::internal::SetupIsolateDelegate::SetupHeap+964784"
    },
    {
      "pc": "0x00007ff71ba93bdc",
      "symbol": "v8::internal::SetupIsolateDelegate::SetupHeap+42524"
    },
    {
      "pc": "0x00007ff71ba93bdc",
      "symbol": "v8::internal::SetupIsolateDelegate::SetupHeap+42524"
    },
    {
      "pc": "0x00007ff71ba91191",
      "symbol": "v8::internal::SetupIsolateDelegate::SetupHeap+31697"
    },
    {
      "pc": "0x00007ff71ba90d7c",
      "symbol": "v8::internal::SetupIsolateDelegate::SetupHeap+30652"
    },
    {
      "pc": "0x00007ff71b5f62d3",
      "symbol": "v8::internal::Execution::CallWasm+1395"
    },
    {
      "pc": "0x00007ff71b5f5c56",
      "symbol": "v8::internal::Execution::Call+182"
    },
    {
      "pc": "0x00007ff71b6c6ecb",
      "symbol": "v8::Function::Call+603"
    },
    {
      "pc": "0x00007ff71af1bcfd",
      "symbol": "napi_call_function+237"
    },
    {
      "pc": "0x00007fffc4372e4c",
      "symbol": "Napi::FunctionReference::Call+220 [...\\sap\\node-rfc\\node_modules\\node-addon-api\\napi-inl.h]:L2591"
    },
    {
      "pc": "0x00007fffc43752a0",
      "symbol": "node_rfc::PrepareAsync::OnOK+1776 [...\\project\\server\\node_modules\\node-rfc\\src\\client.cc]:L319"
    },
    {
      "pc": "0x00007fffc437380d",
      "symbol": "::operator()+61 [...\\sap\\node-rfc\\node_modules\\node-addon-api\\napi-inl.h]:L3842"
    },
    {
      "pc": "0x00007fffc437b93c",
      "symbol": "Napi::details::WrapCallback< >+28 [...\\sap\\node-rfc\\node_modules\\node-addon-api\\napi-inl.h]:L73"
    },
    {
      "pc": "0x00007fffc437374f",
      "symbol": "Napi::AsyncWorker::OnWorkComplete+111 [...\\sap\\node-rfc\\node_modules\\node-addon-api\\napi-inl.h]:L3838"
    },
    {
      "pc": "0x00007ff71af0451c",
      "symbol": "node_module_register+1692"
    },
    {
      "pc": "0x00007ff71af8d950",
      "symbol": "uv_timer_stop+560"
    },
    {
      "pc": "0x00007ff71af8da27",
      "symbol": "uv_timer_stop+775"
    },
    {
      "pc": "0x00007ff71af8a4eb",
      "symbol": "uv_async_send+331"
    },
    {
      "pc": "0x00007ff71af89c8c",
      "symbol": "uv_loop_init+1212"
    },
    {
      "pc": "0x00007ff71af89e54",
      "symbol": "uv_run+244"
    },
    {
      "pc": "0x00007ff71aeabc12",
      "symbol": "v8::internal::Scope::locals+30946"
    },
    {
      "pc": "0x00007ff71af09a73",
      "symbol": "node::Start+275"
    },
    {
      "pc": "0x00007ff71adc667c",
      "symbol": "RC4_options+339324"
    },
    {
      "pc": "0x00007ff71bbc7138",
      "symbol": "v8::internal::SetupIsolateDelegate::SetupHeap+1301368"
    },
    {
      "pc": "0x00007ffff2e07bd4",
      "symbol": "BaseThreadInitThunk+20"
    },
    {
      "pc": "0x00007ffff4dace51",
      "symbol": "RtlUserThreadStart+33"
    }
  ],
clausreinke commented 4 years ago

Diagnostic Report is specifically for this purpose, and debug info is there, so closing here