Automattic / Automattic/node-canvas

node-canvas loads incorrect libcairo

Open
#1,859 2 comments 0 reactions 0 assignees View on GitHub
Binaries
Dominant language
JavaScript
Stars
10.7k
Forks
1.2k
Avg merge
4d 8h
Merged PRs (30d)
1

Description

I am running into a segfault when trying to render a PDF using pdf.js onto a canvas instance.

I have tried to run node with GDB and this is the output. It seems like the segfault happens inside a `libcairo` that comes pre-bundled with another package.

```
free(): invalid pointer

Thread 1 "node" received signal SIGABRT, Aborted.
0x00007ffff7ab19e5 in raise () from /lib64/libc.so.6
(gdb) bt
#0 0x00007ffff7ab19e5 in raise () from /lib64/libc.so.6
#1 0x00007ffff7a9a8a4 in abort () from /lib64/libc.so.6
#2 0x00007ffff7af4007 in __libc_message () from /lib64/libc.so.6
#3 0x00007ffff7afbcdc in malloc_printerr () from /lib64/libc.so.6
#4 0x00007ffff7afd0ac in _int_free () from /lib64/libc.so.6
#5 0x00007fffd74780e5 in ?? ()
from /home/emi/Projects/authory/api/node_modules/sharp/build/Release/../../vendor/lib/libcairo.so.2
#6 0x00007fffd747ae16 in ?? ()
from /home/emi/Projects/authory/api/node_modules/sharp/build/Release/../../vendor/lib/libcairo.so.2
#7 0x00007fffd74e08c0 in ?? ()
from /home/emi/Projects/authory/api/node_modules/sharp/build/Release/../../vendor/lib/libcairo.so.2
#8 0x00007fffd7483a58 in ?? ()
from /home/emi/Projects/authory/api/node_modules/sharp/build/Release/../../vendor/lib/libcairo.so.2
#9 0x00007fffd747da71 in ?? ()
from /home/emi/Projects/authory/api/node_modules/sharp/build/Release/../../vendor/lib/libcairo.so.2
#10 0x00007fffd74f09ca in cairo_paint_with_alpha ()
from /home/emi/Projects/authory/api/node_modules/sharp/build/Release/../../vendor/lib/libcairo.so.2
#11 0x00007fffd4b16d1f in Context2d::DrawImage(Nan::FunctionCallbackInfo const&) ()
from /home/emi/Projects/authory/common/node_modules/node-canvas/build/Release/canvas.node
#12 0x00007fffd4b0b9f8 in Nan::imp::FunctionCallbackWrapper(v8::FunctionCallbackInfo const&) ()
from /home/emi/Projects/authory/common/node_modules/node-canvas/build/Release/canvas.node
[omitted]
```

**When I remove the other package from the project, the code works normally.**

How can I configure node-canvas to load the `libcairo` I have installed on my OS, or another version that is appropriate?

## Environment

canvas@2.8.0
Fedora release 33
Node v12.22.1

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.