-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Segfault on Alpine Linux 3.13 / musl 1.2.2 with prebuilt binaries #2570
Comments
Installing vips-dev and forcing Sharp to build from source seems to be a workaround for this. |
Hello, thank you for the clear details in this report, I can reproduce this locally. Interestingly, using the This smells a bit like an ABI change somewhere between Alpine 3.12 / musl 1.1.24 and Alpine 3.13 / musl 1.2.2. It's possible that the change in lovell/sharp-libvips#81 will help, but otherwise this could be a case of having to (pre)build for musl 1.1.x and musl 1.2.x separately. Initially we can prevent the use of the current prebuilt binaries for musl >=1.2.0 approximately here - https://github.com/lovell/sharp/blob/master/install/libvips.js#L84 |
https://musl.libc.org/time64.html introduced in musl 1.2.0 to deal with the epochalypse (year 2038 problem) is a likely candidate for ABI mismatches. |
Just to say, we're experiencing this also on Alpine 3.13. It took a while to track it down and find this issue because sharp is used by our vendor (Vue Storefront) and all we knew was image generation was causing a segfault. |
Commit 9f2f920 adds an install-time check to prevent prebuilt binaries from being used with musl >= v1.2.0, which will be part of sharp v0.27.2. For sharp v0.28.0+, if lovell/sharp-libvips#81 doesn't fix this, we can consider separate prebuilt binaries for musl 1.1.x vs 1.2.x. |
I've made a little progress on this. It looks like even libvips binaries built on Alpine 3.13 fail in the same manner, which is unexpected. The following two commands are very similar, and when run with sharp v0.27.1 on Alpine 3.13 (as this issue was reported against) one works but the other segfaults: $ node -e "require('sharp')({create:{width:1,height:1,channels:3,background:'red'}}).sharpen().toBuffer().then(console.log)"
<Buffer ff 00 00>
$ node -e "require('sharp')({create:{width:1,height:1,channels:3,background:'red'}}).sharpen(1).toBuffer().then(console.log)"
Segmentation fault (core dumped) The difference is: Lines 194 to 199 in dcf913c
vs: Lines 206 to 207 in dcf913c
musl 1.2.1 introduced a new "mallocng" memory allocator, so that's the next thing to investigate. |
Found it. The segfault occurs when The prebuilt sharp binary is built with C++11 "old" ABI but it looks like the libvips binaries for musl-based Linux were built with C++11 "new" ABI. This hasn't been a problem with the "oldmalloc" allocator, but it is incorrect behaviour between sharp and libvips, and musl's new "mallocng" allocator has exposed this. I'm going to switch all prebuilt Linux binaries to use "new" ABI for the next release, so the forthcoming libvips v8.10.6 and sharp v0.28.0 binaries will be aligned for both glibc and musl Linux. |
Commit 885e959 adds Alpine 3.13 / Node.js 14 to the x64 CI matrix and loosens the semver check. This will be in v0.28.0. |
v0.28.0 now available with prebuilt binaries that will work on musl v1.2.x (as well as musl v1.1.24+). |
Yes
On the alpine:3.13 Docker image, install Sharp and attempt to load an image and run .metadata() on it. Node exits with a segmentation fault.
Running it with gdb attached I get the following backtrace
For it not to segfault
I don't think this is related to the image, I've tried with several.
The text was updated successfully, but these errors were encountered: