Segfault for C++ binding with Go library while cleaning up
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