Sharp: Upgrading from 0.21.3 to 0.22.1 leads to: "undefined symbol: cairo_tag_end" - When using LD_PRELOAD with Electron

Created on 28 Apr 2019  路  4Comments  路  Source: lovell/sharp

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

  System:
    OS: Linux 4.10 Linux Mint 18.3 (Sylvia)
    CPU: (2) x64 Intel(R) Core(TM) i5-4690K CPU @ 3.50GHz
    Memory: 1.16 GB / 3.84 GB
    Container: Yes
    Shell: 4.3.48 - /bin/bash
  Binaries:
    Node: 10.15.1 - /usr/bin/node
    Yarn: 1.13.0 - /usr/bin/yarn
    npm: 6.4.1 - /usr/bin/npm
  Utilities:
    Make: 4.1 - /usr/bin/make
    GCC: 5.4.0 - /usr/bin/gcc
    Git: 2.7.4 - /usr/bin/git
  Languages:
    Bash: 4.3.48 - /bin/bash
    Perl: 5.22.1 - /usr/bin/perl
    Python: 2.7.12 - /usr/bin/python
    Ruby: 2.3.1 - /usr/bin/ruby

What are the steps to reproduce?

cross-env LD_PRELOAD=./node_modules/sharp/vendor/lib/libz.so electron [some args]

What is the expected behaviour?

LD_PRELOAD magically fixes everything like it did with [email protected], if that's possible.

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

Yes I believe so. If a fix or workaround aren't immediately apparent, I think I can put together a repo for this. This doesn't seem to be reproducible though when using LD_PRELOAD on a machine with [email protected] already installed though, so actually such a repo might have OS level requirements to reproduce.

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

Things don't get that far.

Other info

Electron 4.1.5

Love the prebuilt images for Electron 4 and 5! I found some references to this error on the web, but nothing that seemed to point me towards anything actionable

question

Most helpful comment

@lovell, you are amazing!

That got me 99% of the way there! When I preloaded just those though, I got undefined symbol: pango_font_description_get_variations. Tacking libpango to the front of my LD_PRELOAD was the final missing link.

For anyone else who runs into this, the full LD_PRELOAD you'll need is probably:

LD_PRELOAD=node_modules/sharp/vendor/lib/libpango-1.0.so.0:node_modules/sharp/vendor/lib/libcairo.so.2:node_modules/sharp/vendor/lib/libpangocairo-1.0.so.0:node_modules/sharp/vendor/lib/libcairo-gobject.so.2:node_modules/sharp/vendor/lib/libz.so

I'm pretty sure you can whitespace to separate multiple paths, but I used colons.

Thank you again so much for everything!

PS, to anyone using the code I included, I don't really know if I followed best practices with linking to .so.0, or if I should have just linked to .so. I just stopped tinkering when it worked. So far, no issues.

All 4 comments

Hi, this error relates to cairo. Are you using node-canvas also? If so, how is it's cairo dependency installed?

Thanks for your reply @lovell. We're not using of node-canvas.

In case there's anything we can do to work-around Cairo, we're just using Sharp for conversion of jpg and png to webp and nothing more.

Would putting together a repo be the best next step to figure this out? Is there anything else that comes to mind?

Thanks again @lovell!

Thanks, I can see that it is the electron binary itself that depends on the Linux system's libcairo shared libraries:

$ npm install electron
$ ldd node_modules/electron/dist/electron | grep cairo
    libpangocairo-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libpangocairo-1.0.so.0 (0x00007f8797a95000)
    libcairo.so.2 => /usr/lib/x86_64-linux-gnu/libcairo.so.2 (0x00007f8797902000)
    libcairo-gobject.so.2 => /usr/lib/x86_64-linux-gnu/libcairo-gobject.so.2 (0x00007f87953d2000)

If you're already setting LD_PRELOAD then try adding sharp's libcairo to it also (I think multiple paths are space-delimited).

@lovell, you are amazing!

That got me 99% of the way there! When I preloaded just those though, I got undefined symbol: pango_font_description_get_variations. Tacking libpango to the front of my LD_PRELOAD was the final missing link.

For anyone else who runs into this, the full LD_PRELOAD you'll need is probably:

LD_PRELOAD=node_modules/sharp/vendor/lib/libpango-1.0.so.0:node_modules/sharp/vendor/lib/libcairo.so.2:node_modules/sharp/vendor/lib/libpangocairo-1.0.so.0:node_modules/sharp/vendor/lib/libcairo-gobject.so.2:node_modules/sharp/vendor/lib/libz.so

I'm pretty sure you can whitespace to separate multiple paths, but I used colons.

Thank you again so much for everything!

PS, to anyone using the code I included, I don't really know if I followed best practices with linking to .so.0, or if I should have just linked to .so. I just stopped tinkering when it worked. So far, no issues.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AVVS picture AVVS  路  3Comments

henbenla picture henbenla  路  3Comments

kachurovskiy picture kachurovskiy  路  3Comments

jaydenseric picture jaydenseric  路  3Comments

zilions picture zilions  路  3Comments