Skip to content

SVG with linearGradient crashes libcairo in latest prebuilt Linux binaries #1895

Closed

Description

@flunderpero

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

 System:
    OS: Linux 4.14 Ubuntu 19.04 (Disco Dingo)
    CPU: (28) x64 Intel(R) Xeon(R) CPU @ 2.30GHz
    Memory: 5.21 GB / 29.45 GB
    Container: Yes
    Shell: 5.0.3 - /bin/bash
  Binaries:
    Node: 12.8.1 - /usr/bin/node
    Yarn: 1.17.3 - /usr/bin/yarn
    npm: 6.10.2 - /usr/bin/npm
  Utilities:
    Make: 4.2.1 - /usr/bin/make
    GCC: 8.3.0 - /usr/bin/gcc
    Git: 2.20.1 - /usr/bin/git
  Languages:
    Bash: 5.0.3 - /usr/bin/bash
    Perl: 5.28.1 - /usr/bin/perl
    Python: 3.7.3 - /opt/lib/venv/bin/python
    Python3: 3.7.3 - /opt/lib/venv/bin/python3
    Ruby: 2.5.5 - /usr/bin/ruby

What are the steps to reproduce?

Trying to use sharp with this SVG causes a core dump and the message free(): invalid pointer on Ubuntu 19.04. It works as expected on OSX (Mojave).

npm rebuild sharp signals that it is using vendored libvips (it says info sharp Using existing vendored libvips v8.8.1).

What is the expected behaviour?

It should work under Ubuntu 19.04 as it does under OSX Mojave.

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

    const src =
        (await axios.get(
            "https://www.schwoererhaus.de/typo3conf/ext/mq_layout_custom/Resources/Public/Images/main/layout/logo.svg",
            {responseType: "stream"})).data
    const dst = new WritableBuffer()
    await new Promise((resolve, reject) => {
        const sharp_transform = sharp(undefined, {failOnError: false})
            .toFormat("jpeg", {quality: 80})
        src.pipe(sharp_transform)
        .pipe(dst)
        .on("error", reject)
        dst.on("finish", resolve)
    })

Activity

  1. lovell commented on Oct 1, 2019

    @lovell
    Owner

    I can reproduce this. The backtrace suggests there's an invalid free within libcairo.

    #0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
    #1  0x00007ffff7a67535 in __GI_abort () at abort.c:79
    #2  0x00007ffff7ace726 in __libc_message (action=action@entry=do_abort, fmt=fmt@entry=0x7ffff7bf4952 "%s\n") at ../sysdeps/posix/libc_fatal.c:181
    #3  0x00007ffff7ad559a in malloc_printerr (str=str@entry=0x7ffff7bf2a9b "free(): invalid pointer") at malloc.c:5352
    #4  0x00007ffff7ad73cc in _int_free (av=<optimised out>, p=<optimised out>, have_lock=<optimised out>) at malloc.c:4181
    #5  0x00007fffdd6e40e5 in ?? () from /sharp/build/Release/../../vendor/lib/libcairo.so.2
    #6  0x00007fffdd6e6e16 in ?? () from /sharp/build/Release/../../vendor/lib/libcairo.so.2
    #7  0x00007fffdd74c8c0 in ?? () from /sharp/build/Release/../../vendor/lib/libcairo.so.2
    #8  0x00007fffdd6f0375 in ?? () from /sharp/build/Release/../../vendor/lib/libcairo.so.2
    #9  0x00007fffdd6e8c49 in ?? () from /sharp/build/Release/../../vendor/lib/libcairo.so.2
    #10 0x00007fffdd75ccba in cairo_fill () from /sharp/build/Release/../../vendor/lib/libcairo.so.2
    #11 0x00007fffde08b0e0 in ?? () from /sharp/build/Release/../../vendor/lib/librsvg-2.so.2
    

    The prebuilt binaries currently provide cairo v1.17.2 for Linux and v1.16.0 for OS X, so my best guess would be a recent regression to libcairo or in librsvg's use of it.

    The main changes between these two versions are detailed at https://www.cairographics.org/news/cairo-1.17.2/

    If I remove the <linearGradient> element from the example SVG it does not crash.

  2. lovell commented on Oct 2, 2019

    @lovell
    Owner

    This is caused by https://gitlab.freedesktop.org/cairo/cairo/issues/358 and was introduced in libcairo v1.17.2, which is still the most recent release.

  3. added this to the v0.24.0 milestone on Oct 2, 2019
  4. changed the title [-]SVG causes core dump on Ubuntu 19.04[/-] [+]SVG with linearGradient crashes libcairo in latest prebuilt Linux binaries[/+] on Oct 2, 2019
  5. flunderpero commented on Oct 2, 2019

    @flunderpero
    Author

    First of all - wow, you are quick! Thank you.

    So we have to wait for the next release of libcairo then? Judging by their release notes this could take a while. For now we identified just this single SVG causing this after using sharp for months now on our site (https://cilng.com) which allows users to upload images and bookmark pages for which in turn thumbnails are generated.

    For now it is not a huge problem for us, so we'll wait.

  6. lovell commented on Jan 16, 2020

    @lovell
    Owner

    v0.24.0 is now available with a prebuilt libvips v8.9.0 and cairo v1.16.0. Thanks for reporting 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

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions