Skip to content

Sharp crashes on ArchLinux #4348

Closed
Closed

Description

@xsmh

Possible bug

Is this a possible bug in a feature of sharp, unrelated to installation?

  • Running npm install sharp completes without error.
  • Running node -e "require('sharp')" completes without error.

If you cannot confirm both of these, please open an installation issue instead.

Are you using the latest version of sharp?

  • I am using the latest version of sharp as reported by npm view sharp dist-tags.latest.

If you cannot confirm this, please upgrade to the latest version and try again before opening an issue.

If you are using another package which depends on a version of sharp that is not the latest, please open an issue against that package instead.

What is the output of running npx envinfo --binaries --system --npmPackages=sharp --npmGlobalPackages=sharp?

  System:
    OS: Linux 6.13 Arch Linux
    CPU: (24) x64 AMD Ryzen 9 5900X 12-Core Processor
    Memory: 26.15 GB / 31.25 GB
    Container: Yes
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 23.9.0 - /usr/bin/node
    Yarn: 1.22.22 - /usr/bin/yarn
    npm: 11.2.0 - /usr/bin/npm
  npmPackages:
    sharp: ^0.33.5 => 0.33.5 

Does this problem relate to file caching?

The default behaviour of libvips is to cache input files, which can lead to EBUSY or EPERM errors on Windows.
Use sharp.cache(false) to switch this feature off.

  • Adding sharp.cache(false) does not fix this problem.

Does this problem relate to images appearing to have been rotated by 90 degrees?

Images that contain EXIF Orientation metadata are not auto-oriented. By default, EXIF metadata is removed.

  • To auto-orient pixel values use the parameter-less rotate() operation.

  • To retain EXIF Orientation use keepExif().

  • Using rotate() or keepExif() does not fix this problem.

What are the steps to reproduce?

Use Sharp to resize an image and write output to buffer from an Electron app started with Electron Forge.

What is the expected behaviour?

The code runs fine on Debian but throws this error on Arch. It also works as expected when I run the same code outside of the Electron app on Arch.

ERROR:/__w/sharp/sharp/node_modules/@img/sharp-libvips-dev/include/vips/VImage8.h:134
:vips::VObject& vips::VObject::operator=(const vips::VObject&): assertion failed: (!a
.vobject || VIPS_IS_OBJECT(a.vobject))
Bail out! ERROR:/__w/sharp/sharp/node_modules/@img/sharp-libvips-dev/include/vips/VIm
age8.h:134:vips::VObject& vips::VObject::operator=(const vips::VObject&): assertion f
ailed: (!a.vobject || VIPS_IS_OBJECT(a.vobject))

Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem

I'm unable to provide that at the moment as it is hard to judge which part of the code is causing the issue, especially since the same code works fine on Debian. One thing I know for sure after debugging is that it crashes on toBuffer. Hoping to get some insight into what may be causing it on one distro but not another.

Activity

  1. xsmh commented on Mar 18, 2025

    @xsmh
    Author

    A few others seemed to have had the same issue here #4129

  2. lovell commented on Mar 18, 2025

    @lovell
    Owner

    My best guess would be that this relates to a glib version mismatch.

    Electron dynamically links against the system glib whereas the prebuilt libvips binaries provided by sharp statically link against their own glib and attempt to force its use internally via -Bsymbolic-functions.

    https://github.com/lovell/sharp-libvips/blob/4e1ebe2c69982382d398a3cf7f1d5e536a114542/build/lin.sh#L465

    There has been at least one previous Electron issue relating to the provision of statically-linked binaries - see electron/electron#25495

    Perhaps try the pre-release version of sharp 0.34.0-rc.0, which provides the latest glib 2.84.0 - see #4248 (comment)

  3. xsmh commented on Mar 18, 2025

    @xsmh
    Author

    Hey @lovell, the pre-release version works perfectly, thank you!

  4. lovell commented on Mar 18, 2025

    @lovell
    Owner

    Thanks for confirming - please subscribe to #4248 for updates.

  5. Bilb commented on Oct 13, 2025

    @Bilb

    Hey @lovell
    Is it possible that this issue is back?
    I have a bunch of users on archlinux reporting that anything image-*related is making the app crash, like those:
    session-foundation/session-desktop#1626
    session-foundation/session-desktop#1602
    session-foundation/session-desktop#1618

    The packaged sharp version is 0.34.4.
    I do reproduce this issue myself in an archlinux virtual machine (cachyOS).
    Any help to debug this issue would be greatly appreciated.

  6. Bilb commented on Oct 13, 2025

    @Bilb

    Let me know if you'd prefer have another issue open for this.
    Here is what I could get from the electron dump

    Thread 25 (crashed)
     0  0x0
        rax = 0x0000000000000001   rdx = 0x0000000000000000
        rcx = 0x00007ffff7a232e0   rbx = 0x00002d0405827700
        rsi = 0x0000000000000000   rdi = 0x00002d0405827710
        rbp = 0x0000000000000001   rsp = 0x00007ffe2a12a0a8
         r8 = 0x00007ffe2a12a100    r9 = 0x0000000000000001
        r10 = 0x0000000000000000   r11 = 0x00007ffe287dc270
        r12 = 0x00002d0405827708   r13 = 0x00002d0405827710
        r14 = 0x00007ffefe4f341c   r15 = 0x0000555560519300
        rip = 0x0000000000000000
        Found by: given as instruction pointer in context
     1  libgobject-2.0.so.0 + 0x22643
        rsp = 0x00007ffe2a12a0b0   rip = 0x00007ffff7a33643
        Found by: stack scanning
     2  sharp-linux-x64.node + 0x5241c
        rsp = 0x00007ffe2a12a150   rip = 0x00007ffefe4f341c
        Found by: stack scanning
     3  electron!crabby_avifFree + 0x672690
        rsp = 0x00007ffe2a12a158   rip = 0x0000555560519300
        Found by: stack scanning
     4  sharp-linux-x64.node + 0x1835d
        rsp = 0x00007ffe2a12a160   rip = 0x00007ffefe4b935d
        Found by: stack scanning
     5  sharp-linux-x64.node + 0x2000c
        rsp = 0x00007ffe2a12a170   rip = 0x00007ffefe4c100c
        Found by: stack scanning
     6  libc.so.6 + 0xa644f
        rsp = 0x00007ffe2a12a180   rip = 0x00007ffff62a644f
        Found by: stack scanning
     7  libc.so.6 + 0xa97bc
        rsp = 0x00007ffe2a12a1d0   rip = 0x00007ffff62a97bc
        Found by: stack scanning
     8  electron!crabby_avifFree + 0x672658
        rsp = 0x00007ffe2a12a200   rip = 0x00005555605192c8
        Found by: stack scanning
     9  electron!crabby_avifFree + 0x672638
        rsp = 0x00007ffe2a12a248   rip = 0x00005555605192a8
        Found by: stack scanning
    10  electron!crabby_avifFree + 0x672690
        rsp = 0x00007ffe2a12a250   rip = 0x0000555560519300
        Found by: stack scanning
    11  sharp-linux-x64.node + 0x16eac
        rsp = 0x00007ffe2a12a260   rip = 0x00007ffefe4b7eac
        Found by: stack scanning
    12  electron!crabby_avifFree + 0x672610
        rsp = 0x00007ffe2a12a270   rip = 0x0000555560519280
        Found by: stack scanning
    13  libc.so.6 + 0xaf763
        rsp = 0x00007ffe2a12a280   rip = 0x00007ffff62af763
        Found by: stack scanning
    14  electron!crabby_avifFree + 0x672610
        rsp = 0x00007ffe2a12a288   rip = 0x0000555560519280
        Found by: stack scanning
    15  electron!node::AsyncResource::~AsyncResource() + 0x368
        rsp = 0x00007ffe2a12a2a0   rip = 0x000055555fa895b8
        Found by: stack scanning
    16  electron!uv_cancel + 0x24b
        rsp = 0x00007ffe2a12a2b0   rip = 0x0000555557957b4b
        Found by: stack scanning
    17  electron!uv_cancel + 0x180
        rsp = 0x00007ffe2a12a2b8   rip = 0x0000555557957a80
        Found by: stack scanning
    18  libc.so.6 + 0xaa4f8
        rsp = 0x00007ffe2a12a2f0   rip = 0x00007ffff62aa4f8
        Found by: stack scanning
    19  libc.so.6 + 0xaa240
        rsp = 0x00007ffe2a12a3b0   rip = 0x00007ffff62aa240
        Found by: stack scanning
    20  libc.so.6 + 0x140fdc
        rsp = 0x00007ffe2a12a3c0   rip = 0x00007ffff6340fdc
        Found by: stack scanning
    
    
  7. lovell commented on Oct 13, 2025

    @lovell
    Owner

    @Bilb This comment session-foundation/session-desktop#1602 (comment) nails the underlying problem, there's really not a lot we can do. You'll need to either switch electron to statically-link against all of its dependencies or switch sharp to use an OS-managed libvips shared library (to match electron's use of OS-managed shared libaries).

  8. Bilb commented on Oct 14, 2025

    @Bilb

    @lovell thanks for you reply. I guess using the OS managed libvips is going to be easier for my usecase.
    Does it mean I'll loose some important options/performance tweaks of the sharp-built one?

  9. Bilb commented on Oct 26, 2025

    @Bilb

    Ok, thanks a lot about that info. I'll see what I can do when I got some time to deal with this.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions