The keccak package sometimes causes segfaults on Node v14
davidmurdoch opened this issue · comments
I'm sorry my reproduction steps are so horrible... but I just haven't been able to figure out how to reliably trigger the error.
To reproduce:
git clone https://github.com/trufflesuite/ganache-core.git
cd ganache-core
git checkout 8a4fb09c970d2ded061c1b1e1fd912cd7ae0229a
nvm use 14
npm ci
npm test
(you may have to run this many times until you trigger the segfault)
You should see something like:
Segmentation fault (core dumped)
npm ERR! code 139
npm ERR! path /home/david/work/ganache-core
npm ERR! command failed
npm ERR! command sh -c mocha --check-leaks --recursive "./test/local"
npm ERR! A complete log of this run can be found in:
npm ERR! /home/david/.npm/_logs/2020-10-07T15_21_43_948Z-debug.log
(The debug log isn't helpful)
I've somewhat "fixed" this in ganache-core
by patching keccak
so it never loads the native modules.
To reproduce my workaround:
git checkout c26ba24ebf24d1c09b328a76baf0cf43e82fba04
npm ci
(if you are using npm 7.0.0-rc.0 you'll need to also runnpm run postinstall
)npm test
(run it as many times as you'd like; it doesn't crash anymore... I ran the tests for over an hour viawhile npm test; do :; done
without a crash)
Here is the patch, if you're curious: https://github.com/trufflesuite/ganache-core/blob/c26ba24ebf24d1c09b328a76baf0cf43e82fba04/patches/keccak%2B3.0.1.patch#L1-L11
The biggest issue with my workaround is that patch-package
isn't safe to use in published npm modules. :-(
I've also opened the issue in keccak, but I figured it might be faster/easier to update this package to do something like const keccak = require("keccack/js");
(untested) than it would be to get keccak to find and fix this in the native code.
Note: removing nyc
from the test
command reduces the likelihood of the crash, however, it does still occur when running with mocha
only.
Hey @davidmurdoch, which platform are you running this on? Linux?
Linux (Kubuntu 20.04), yes. But I've seen it fail in CI on Mac as well.
I've updated cryptocoinjs/keccak#19 with some additional information.
We're no longer using native code in v0.2, so the upgrade fixes it.
Hey @davidmurdoch,
I think you will find it useful that we released 1.0.0, which doesn't use any native module (no possible segfault), and has been audited by Cure53.
I read on Twitter that Ganache migrated to native bigints, so you should be able to migrate to 1.0.0 🚀
Closing, since 1.x is the future.