openpeeps / denim

Node 💖 Nim = Denim! Build powerful NodeJS / BunJS addons with Nim language via Node API (NAPI)
https://openpeeps.github.io/denim/
MIT License
41 stars 1 forks source link

Frequent: SIGSEGV: Illegal storage access. (Attempt to read from nil?) #8

Closed jfilby closed 1 year ago

jfilby commented 1 year ago

My node module is causing Node to die quite often. It is typically (always?) a Nim GC function:

$HOME/.choosenim/toolchains/nim-1.6.14/lib/system/gc.nim(486) newObj
$HOME/.choosenim/toolchains/nim-1.6.14/lib/system/gc_common.nim(422) prepareDealloc

I'm not sure if a different GC would help, I think Denim uses the default? I usually specify the ORC GC when compiling the code I'm using for the node addon. I think it might help if Denim had an option to pass in extra args to the Nim compiler called by the Denim build command.

georgelemon commented 1 year ago

Actually, you can create a .nims file:

when defined napibuild:
  --define:release

useMalloc is added by default in build command. Maybe I should remove that so you can have full control

jfilby commented 1 year ago

I'm a bit late to use .nims files, but this worked perfectly. I set the GC to ORC. So far no sign of the error, and I've tested quite thoroughly. I think useMalloc should indeed be optional (not added by default).