-
-
Notifications
You must be signed in to change notification settings - Fork 224
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
JS binding segfaults in worker thread #518
Comments
See #517 |
Yeah I completely agree with you, I was thinking that maybe the minifier may have some memory that need cleaning up internally, but I was also fearing that the go runtime has internal memory used by its runtime... since you mention that calling an empty function results in a segfault as well, it seems option number 2 is correct ><;; |
It feels really bad after all the hard work on the C++ bindings, but maybe worth it to look into |
Maybe related: https://tinygo.org/docs/guides/webassembly/ |
Hm going the WASM way would be possible but I'm unsure about the implications. I've added a sleep function to avoid races, it seems to work locally, can you verify? |
Doesn't seem to help much, or only sometimes. I'm out of ideas, but honestly this is not the only library that fails with worker threads. Is this a common way to use NAPI libraries? How important is supporting worker threads? |
I think it would be pretty common. NAPI libraries are usually used to perform CPU heavy tasks, and it's also critical to run them in separate threads to avoid blocking the event loop. Also it enables running this library in parallel... |
But it's ok, it's not urgent to fix this :) |
Hopefully answers to this issue might shed some light: nodejs/node-gyp#2695 |
This has likely to do with a very similar issue with the Python binding, see #535 (comment) Basically, Go cannot be forked since it will only fork the main thread and not the GC thread. The forked threads from the main thread then hang when trying to garbage collect. For some reason, the fix is quite the inverse: for Python we should load the library in each thread (or use the spawning instead of the forking strategy). For JS we need to load the library globally and call its functions in each thread, apparently the |
From #379: the worker test case fails due to a race condition. Even when calling an empty function in Go it fails. It gets stuck at
worker.terminate()
when callingruntime.GC()
in the clean up function. Looks like something we need to take up with Go or with Node.The text was updated successfully, but these errors were encountered: