Skip to content
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

[bug] keccak does not work in linux alpine image #15

Closed
wanseob opened this issue Jul 16, 2020 · 7 comments
Closed

[bug] keccak does not work in linux alpine image #15

wanseob opened this issue Jul 16, 2020 · 7 comments

Comments

@wanseob
Copy link

wanseob commented Jul 16, 2020

Tested the tutorial on node:12-alpine docker image shell but failed. Tutorial works well on Ubuntu.

It failed when I try to call update() function with "Segmentation fault (core dumped)" error.

@wanseob
Copy link
Author

wanseob commented Jul 16, 2020

@alcuadrado
Copy link

@wanseob can you help me reprodce this? Do you have a link to some place where I can do it?

@PhilippLgh
Copy link

PhilippLgh commented Jul 16, 2020

here is a very basic test:

docker run --rm -it node:alpine /bin/sh

/ # cat /etc/os-release
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.11.6
PRETTY_NAME="Alpine Linux v3.11"
HOME_URL="https://alpinelinux.org/"
BUG_REPORT_URL="https://bugs.alpinelinux.org/"

/ # mkdir test
/ # cd test
/ # npm init -y
/ # npm install --save keccak

> keccak@3.0.0 install /node_modules/keccak
> node-gyp-build || exit 0

npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN @1.0.0 No description
npm WARN @1.0.0 No repository field.

+ keccak@3.0.0
added 3 packages from 52 contributors and audited 3 packages in 1.643s
found 0 vulnerabilities

/ # node
Welcome to Node.js v14.5.0.
Type ".help" for more information.
> const createKeccakHash = require('keccak')
> createKeccakHash('keccak256').digest().toString('hex')
'c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470'
> createKeccakHash('keccak256').update('Hello')
Segmentation fault

@alcuadrado
Copy link

Hey @fanatid,

I dug deeper into this, and I now understand what's going on. The Linux version of this package is being built using glibc, but Alpine Linux (a super popular distro in Docker-land) uses another libc. These are not compatible with each other, so the module ends up crashing.

I asked about this in the prebuildify repo and they told me about two things that can be done here:

  1. Use a prebuildify param that tags the prebuilds with the libc used at build time. This is then understood by node-gyp-build, which will use the js fallback if the system libc doesn't have a prebuilt.

  2. prebuildify-cross can be used to also crosscompile a version for Alpine Linux, so that a native version can be used in that distro.

I think (1) is pretty easy to implement, but maybe not so much to test, and that (2) is really nice to have, but requires more work, and can be added in the future.

If you agree with this, I can send a PR implementing (1).

Also, this same problem is probably present in secp256k1.

@fanatid
Copy link
Member

fanatid commented Jul 16, 2020

Thanks for digging! If first sounds easy we can choose this way right now and try a better solution later. Probably I'll able check this issue on weekend.

@fanatid
Copy link
Member

fanatid commented Jul 20, 2020

Published as 3.0.1.

@fanatid fanatid closed this as completed Jul 20, 2020
@alcuadrado
Copy link

Awesome! Thanks for doing both releases!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants