Closed Kikobeats closed 2 years ago
Same thing, but reproduces only in ava v4 with workerThreads enabled, turning off workerThreads fixes the problem. Here is my stacktrace:
FROM node:16.13.1-slim
, esm-enabled code
> NODE_ENV=test NODE_OPTIONS=--enable-source-maps ./node_modules/.bin/ava
Fatal error condition occurred in /codebuild/output/src422080616/src/aws-crt-nodejs/source/module.c:603: s_node_uv_elg == NULL
Exiting Application
################################################################################
Stack trace:
################################################################################
/srv/shorturl_redirector/node_modules/aws-crt/dist/bin/linux-x64/aws-crt-nodejs.node(aws_backtrace_print+0x41) [0x7fe50c825d21]
/srv/shorturl_redirector/node_modules/aws-crt/dist/bin/linux-x64/aws-crt-nodejs.node(aws_fatal_assert+0x43) [0x7fe50c81b0f3]
/srv/shorturl_redirector/node_modules/aws-crt/dist/bin/linux-x64/aws-crt-nodejs.node(napi_register_module_v1+0x9e6) [0x7fe50c5fee36]
node(_Z30napi_module_register_by_symbolN2v85LocalINS_6ObjectEEENS0_INS_5ValueEEENS0_INS_7ContextEEEPFP12napi_value__P10napi_env__S8_E+0x351) [0xac7dc1]
node() [0xacc367]
node(_ZN4node7binding6DLOpenERKN2v820FunctionCallbackInfoINS1_5ValueEEE+0x2c3) [0xacc893]
node() [0xd4a35e]
node(_ZN2v88internal21Builtin_HandleApiCallEiPmPNS0_7IsolateE+0xaf) [0xd4b77f]
node() [0x15e78f9]
Signal received: 1866676063, errno: 2019914862
################################################################################
Stack trace:
################################################################################
/srv/shorturl_redirector/node_modules/aws-crt/dist/bin/linux-x64/aws-crt-nodejs.node(aws_backtrace_print+0x41) [0x7fe50c825d21]
/srv/shorturl_redirector/node_modules/aws-crt/dist/bin/linux-x64/aws-crt-nodejs.node(+0x652d3) [0x7fe50c5fd2d3]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x12730) [0x7fe51ffa7730]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0x10b) [0x7fe51fe0b7bb]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x121) [0x7fe51fdf6535]
/srv/shorturl_redirector/node_modules/aws-crt/dist/bin/linux-x64/aws-crt-nodejs.node(+0x2830f8) [0x7fe50c81b0f8]
/srv/shorturl_redirector/node_modules/aws-crt/dist/bin/linux-x64/aws-crt-nodejs.node(napi_register_module_v1+0x9e6) [0x7fe50c5fee36]
node(_Z30napi_module_register_by_symbolN2v85LocalINS_6ObjectEEENS0_INS_5ValueEEENS0_INS_7ContextEEEPFP12napi_value__P10napi_env__S8_E+0x351) [0xac7dc1]
node() [0xacc367]
node(_ZN4node7binding6DLOpenERKN2v820FunctionCallbackInfoINS1_5ValueEEE+0x2c3) [0xacc893]
node() [0xd4a35e]
node(_ZN2v88internal21Builtin_HandleApiCallEiPmPNS0_7IsolateE+0xaf) [0xd4b77f]
node() [0x15e78f9]
Signal received: 0, errno: 0
################################################################################
Stack trace:
################################################################################
/srv/shorturl_redirector/node_modules/aws-crt/dist/bin/linux-x64/aws-crt-nodejs.node(aws_backtrace_print+0x41) [0x7fe50c825d21]
/srv/shorturl_redirector/node_modules/aws-crt/dist/bin/linux-x64/aws-crt-nodejs.node(+0x652d3) [0x7fe50c5fd2d3]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x12730) [0x7fe51ffa7730]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0x10b) [0x7fe51fe0b7bb]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x121) [0x7fe51fdf6535]
node() [0xa315d8]
/lib/x86_64-linux-gnu/libc.so.6(+0x39d8c) [0x7fe51fe0dd8c]
/lib/x86_64-linux-gnu/libc.so.6(+0x39eba) [0x7fe51fe0deba]
/srv/shorturl_redirector/node_modules/aws-crt/dist/bin/linux-x64/aws-crt-nodejs.node(+0x652dd) [0x7fe50c5fd2dd]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x12730) [0x7fe51ffa7730]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0x10b) [0x7fe51fe0b7bb]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x121) [0x7fe51fdf6535]
/srv/shorturl_redirector/node_modules/aws-crt/dist/bin/linux-x64/aws-crt-nodejs.node(+0x2830f8) [0x7fe50c81b0f8]
/srv/shorturl_redirector/node_modules/aws-crt/dist/bin/linux-x64/aws-crt-nodejs.node(napi_register_module_v1+0x9e6) [0x7fe50c5fee36]
node(_Z30napi_module_register_by_symbolN2v85LocalINS_6ObjectEEENS0_INS_5ValueEEENS0_INS_7ContextEEEPFP12napi_value__P10napi_env__S8_E+0x351) [0xac7dc1]
node() [0xacc367]
node(_ZN4node7binding6DLOpenERKN2v820FunctionCallbackInfoINS1_5ValueEEE+0x2c3) [0xacc893]
node() [0xd4a35e]
node(_ZN2v88internal21Builtin_HandleApiCallEiPmPNS0_7IsolateE+0xaf) [0xd4b77f]
node() [0x15e78f9]
Signal received: 0, errno: 0
################################################################################
Stack trace:
################################################################################
/srv/shorturl_redirector/node_modules/aws-crt/dist/bin/linux-x64/aws-crt-nodejs.node(aws_backtrace_print+0x41) [0x7fe50c825d21]
/srv/shorturl_redirector/node_modules/aws-crt/dist/bin/linux-x64/aws-crt-nodejs.node(+0x652d3) [0x7fe50c5fd2d3]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x12730) [0x7fe51ffa7730]
[0x66457d0]
I don't really know anything about ava v4 but the thread-crash vs. process-no-crash as well as the call stacks make me wonder if the issue is with NAPI module multi-init. The CRT does not support multi-init of its native module right now and if multiple inits get invoked within the same process it's going to crash. If that is indeed the root problem, I don't have a timeline when it will get fixed. It's in the backlog, but we haven't had a pressing external stimulus to get it prioritized.
Can you at least add a human-readable node exception? Crashing process, which destroys all connections in the middle of request is not the best way to communicate about errors
If you're able to provide from-scratch step-by-step repro, I can try and squeeze something in.
repro.js:
import { Worker, isMainThread, parentPort } from 'worker_threads';
const worker = new Worker('./reproWorker.js');
reproWorker.js:
import 'aws-crt';
package.json:
{
"name": "repro",
"version": "1.0.0",
"description": "",
"main": "index.js.js",
"type": "module",
"author": "",
"license": "ISC",
"dependencies": {
"aws-crt": "1.10.5"
},
"devDependencies": {
}
}
Segfault here
How does ava factor in?
By default they use worker threads for running tests. To provide a minimal repro I removed ava and loaded worker threads directly
Correct me if I'm wrong, but potentially this library is broken for any other dependency or user code that uses worker_threads
API.
Correct me if I'm wrong, but potentially this library is broken for any other dependency or user code that uses worker_threads API.
Not potentially, it is. The bigger problem is that it kills whole node process instead of raising an exception
v1.10.6 now throws an exception if the module init is called more than once.
This is happening using ava@4 as test runner.
Environment information
Stack trace error