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

Random crash using koffi in node:worker_thread #190

Open
nomagick opened this issue Sep 10, 2024 · 2 comments
Open

Random crash using koffi in node:worker_thread #190

nomagick opened this issue Sep 10, 2024 · 2 comments

Comments

@nomagick
Copy link

nomagick commented Sep 10, 2024

Koffi version: 2.9.0
Node version: 20.16.0

I encounter seemingly random crashes while using koffi in node:worker_thread.
It does not crash most of the time, but crashes could be found in the logs.

Both node main thread and the worker thread load the same lib(libmagic) using koffi.
https://www.npmjs.com/package/libmagic-ffi?activeTab=code

Seems random; the probability is roughly 1% - 5%

INFO 2024-09-10T03:58:15.916631Z Default STARTUP TCP probe succeeded after 1 attempt for container "worker" on port 8080.
DEFAULT 2024-09-10T03:59:11.093376Z FATAL ERROR: Error::ThrowAsJavaScriptException napi_throw
DEFAULT 2024-09-10T03:59:11.093437Z ----- Native stack trace -----
DEFAULT 2024-09-10T03:59:11.093455Z 1: 0x55919c5714fb node::OnFatalError(char const*, char const*) [node]
DEFAULT 2024-09-10T03:59:11.093904Z 2: 0x55919c680732 napi_fatal_error [node]
DEFAULT 2024-09-10T03:59:11.094033Z 3: 0x7f2948427aa7 [/workspace/node_modules/koffi/build/koffi/linux_x64/koffi.node]
DEFAULT 2024-09-10T03:59:11.094231Z 4: 0x7f294842b979 [/workspace/node_modules/koffi/build/koffi/linux_x64/koffi.node]
DEFAULT 2024-09-10T03:59:11.094665Z 5: 0x7f29483ecd55 RG::AsyncCall::OnOK() [/workspace/node_modules/koffi/build/koffi/linux_x64/koffi.node]
DEFAULT 2024-09-10T03:59:11.094677Z 6: 0x7f294842de73 Napi::AsyncWorker::OnWorkComplete(Napi::Env, napi_status) [/workspace/node_modules/koffi/build/koffi/linux_x64/koffi.node]
DEFAULT 2024-09-10T03:59:11.095659Z 7: 0x55919c6841a8 node::ThreadPoolWork::ScheduleWork()::{lambda(uv_work_s*, int)#2}::_FUN(uv_work_s*, int) [node]
DEFAULT 2024-09-10T03:59:11.096810Z 8: 0x55919d3683b9 [node]
DEFAULT 2024-09-10T03:59:11.098983Z 9: 0x55919d36c793 [node]
DEFAULT 2024-09-10T03:59:11.099616Z 10: 0x55919d382d93 [node]
DEFAULT 2024-09-10T03:59:11.101273Z 11: 0x55919d36d607 uv_run [node]
DEFAULT 2024-09-10T03:59:11.102175Z 12: 0x55919c6302b1 node::Environment::CleanupHandles() [node]
DEFAULT 2024-09-10T03:59:11.103005Z 13: 0x55919c630368 node::Environment::RunCleanup() [node]
DEFAULT 2024-09-10T03:59:11.104030Z 14: 0x55919c5cbdf7 node::FreeEnvironment(node::Environment*) [node]
DEFAULT 2024-09-10T03:59:11.104732Z 15: 0x55919c7d7407 node::worker::Worker::Run() [node]
DEFAULT 2024-09-10T03:59:11.105593Z 16: 0x55919c7d781c [node]
DEFAULT 2024-09-10T03:59:11.105607Z 17: 0x7f294a73eac3 [/lib/x86_64-linux-gnu/libc.so.6]
DEFAULT 2024-09-10T03:59:11.105696Z 18: 0x7f294a7d0850 [/lib/x86_64-linux-gnu/libc.so.6]
WARNING 2024-09-10T03:59:11.140943Z Container terminated on signal 11.

@nomagick nomagick changed the title Issue ussing koffi in node:worker_thread Random crash using koffi in node:worker_thread Sep 10, 2024
@Koromix
Copy link
Owner

Koromix commented Sep 18, 2024

I'd like to look into this soon.
Do you have a complete or code base and a way for me to test and reproduce this easily?

@nomagick
Copy link
Author

This was inside Google Firebase Functions v2, on Google Cloud Run.

I'll try to reproduce and create a separate repo then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants