Skip to content

Segfault on Alpine Linux 3.13 / musl 1.2.2 with prebuilt binaries #2570

@cnorthwood

Description

@cnorthwood

Are you using the latest version? Is the version currently in use as reported by npm ls sharp the same as the latest version as reported by npm view sharp dist-tags.latest?

Yes

What are the steps to reproduce?

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

Thread 8 "node" received signal SIGSEGV, Segmentation fault.
[Switching to LWP 212]
0x00007f32ddaedc59 in ?? () from /lib/ld-musl-x86_64.so.1
(gdb) bt
#0  0x00007f32ddaedc59 in ?? () from /lib/ld-musl-x86_64.so.1
#1  0x000000007e000000 in ?? ()
#2  0x00007f32d8abc900 in ?? ()
#3  0x00007f32d6bed610 in ?? ()
#4  0x00007f32daaf2820 in ?? ()
#5  0x00007f32daaf38d0 in ?? ()
#6  0x00007f32d89ddbba in vips::VImage::call_option_string(char const*, char const*, vips::VOption*) ()
   from /app/node_modules/sharp/build/Release/../../vendor/8.10.5/lib/libvips-cpp.so.42
#7  0x00007f32d89f9ece in vips::VImage::new_from_file(char const*, vips::VOption*) ()
   from /app/node_modules/sharp/build/Release/../../vendor/8.10.5/lib/libvips-cpp.so.42
#8  0x00007f32d8a26f38 in sharp::OpenInput(sharp::InputDescriptor*) () from /app/node_modules/sharp/build/Release/sharp.node
#9  0x00007f32d8a2f2dc in MetadataWorker::Execute() () from /app/node_modules/sharp/build/Release/sharp.node
#10 0x00007f32d8a2bb94 in Napi::AsyncWorker::OnAsyncWorkExecute(napi_env__*, void*) () from /app/node_modules/sharp/build/Release/sharp.node
#11 0x000055d831f6c17e in ?? ()
#12 0x00007f32ddb1d160 in ?? () from /lib/ld-musl-x86_64.so.1
#13 0x0000000000000000 in ?? ()

What is the expected behaviour?

For it not to segfault

Are you able to provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem?

docker run --rm -it alpine:3.13
apk add nodejs npm
npm install sharp
(outside the container) docker cp image.jpg <container ID>:/image.jpg
node -e 'new require("sharp")("image.jpg").metadata()'

Are you able to provide a sample image that helps explain the problem?

I don't think this is related to the image, I've tried with several.

What is the output of running npx envinfo --binaries --system?

/ # npx envinfo --binaries --system
npx: installed 1 in 0.988s

  System:
    OS: Linux 4.19 Alpine Linux
    CPU: (6) x64 Intel(R) Core(TM) i7-8700B CPU @ 3.20GHz
    Memory: 11.66 GB / 15.64 GB
    Container: Yes
    Shell: 1.32.1 - /bin/ash
  Binaries:
    Node: 14.15.4 - /usr/bin/node
    npm: 6.14.10 - /usr/bin/npm

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions