Segfault for C++ binding with Go library while cleaning up
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 10.7k
- Forks
- 1.9k
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 5
Description
This may be a long shot but we're out of ideas. we have a Go library with JS bindings, see https://github.com/tdewolff/minify/tree/master/bindings/js which builds a Go library (using MingW) to a C archive, then we use that together with the C file to build the NAPI binary. I use GitHub actions to build on each platform, see https://github.com/tdewolff/minify/blob/master/.github/workflows/nodejs.yml.
For some reason, executing https://github.com/tdewolff/minify/blob/master/bindings/js/test/worker.js gives a segfault right at the end (see https://github.com/tdewolff/minify/runs/7293049169?check_suite_focus=true#step:6:74) which happens while running await worker.terminate(). Is there a way to debug this segfault? It is likely a race condition since it doesn't always happen. Something probably to do with the Go garbage collector, even though turning it off doesn't fix the problem.
How can I debug this segfault? The segfault-handler package doesn't seem to support ES6 import syntax, but converting the worker.js above to a CommonJS format doesn't usually cause a segfault and if it does the handler doesn't catch it.
PS: segfault happens on Ubuntu/Arch, but not on MacOS. For Windows I run into another problem
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with bindings/js/test/worker.js and the .github/workflows/nodejs.yml workflow, then inspect how the Go library is built into a C archive and used by the N-API binary. Reproduce the cleanup crash on Ubuntu or Arch and compare behavior across platforms. Done requires identifying the cause of the intermittent segfault and documenting or implementing a verified resolution.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, github-actions, go, node.js
- Domain
- build-system, devtools
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100