Closed danielSONCCO closed 4 years ago
The "undefined symbol: napi_create_error" error when running foo.c
is because sharp requires symbols from node
itself but the runtime linker hasn't been told about them (the precompiled binaries are designed to be opened by the node process rather than third-party C code), so this is a bit of a red herring.
The prebuilt binaries provided by v0.26.0+ are statically linked, which might be exposing an existing permissions problem with your set up.
Perhaps the use of sudo
in sudo n stable
is causing this? Tools such as n
are generally designed to avoid the use of root/sudo (a good thing).
A backtrace from node
crashing (rather than foo
) might provide more relevant information.
@lovell Thank you very much for your answer.
Perhaps the use of sudo in sudo n stable is causing this?
n stable
isn't working because it tries to make the directory /usr/local/n/versions/node/12.18.4
and rights of /usr/local
are 755.
That's the usual rights right?
A backtrace from
node main.js
crashing might provide more relevant information
Do you know a way to get a detailed backtrace?
Using segfault-handler
I obtained:
PID 6747 received SIGSEGV for address: 0x0
/home/daniel/360/simplified_case_sharp/node_modules/segfault-handler/build/Release/segfault-handler.node(+0x2d66)[0x7f6ad99f9d66]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x128a0)[0x7f6adc8048a0]
n stable isn't working because it tries to make the directory /usr/local/n/versions/node/12.18.4 and rights of /usr/local are 755. That's the usual rights right?
Please see https://github.com/tj/n#installation for avoiding the need to use sudo. https://github.com/tj/n/pull/593 might also be relevant.
Do any of these problems occur if you install node via a means other than n
?
@lovell
Do any of these problems occur if you install node via a means other than n?
Yes. Now I followed those steps and it's still crashing
node/npm/yarn/n
sudo npm i yarn -g
. sudo
is needed because it writes /usr/lib/node_modules/yarn
rm -rf node_modules yarn.lock
yarn install
node main.js
Does this occur if you use npm install
rather than yarn install
?
Please can you provide a Dockerfile with the exact environment and configuration that causes this to allow someone else to reproduce it.
@lovell
Does this occur if you use npm install rather than yarn install?
Yes.
Please can you provide a Dockerfile with the exact environment and configuration that causes this to allow someone else to reproduce it.
I tried to reproduce it in a Dockerfile but the Dockerfile is succeeding.
I also tried to reset my setup to ensure I'm aligned with that Dockerfile but I still see the issue.
But I found a way to use gdb
with node main.js
and now I see this backtrace.log
I'd be glad if you can provide me a libvips.so.42
compiled with -g
.
Like that I can see which of my files has the issue with permission rights.
The scripts and environments that build the libvips binaries provided by sharp are all open source so you can adapt them as you need - see https://github.com/lovell/sharp-libvips
@lovell Thanks ! It fixed my issue.
I executed sudo ./build.sh 8.10.0 linux-x64
on master
Then I replaced my cached file ~/.npm/_libvips/libvips-8.10.0-linux-x64.tar.br
by the generated one
Now sharp
is working normally
Note: executing build.sh
I found two details:
VERSION_SVG=2.50.0
is out of date, I fixed replacing 2.50.0
by 2.50.1
curl -Ls https://download.osgeo.org/libtiff/tiff-${VERSION_TIFF}.tar.gz | tar xzC ${DEPS}/tiff --strip-components=1
isn't working because of expired certificates of the url. I fixed replacing -Ls
by -Lsk
I'm still unsure what was wrong with your set up, but glad you got it working.
I've notified OSGeo about their cert - https://twitter.com/lovell/status/1312422320355577856
@lovell I discarded https://github.com/lovell/sharp-libvips/commit/942a585783676d0e068bf533eaaddb1d3cab1d7f because the tarball without heif
is also working with my scenario.
So I think it's https://github.com/lovell/sharp-libvips/commit/8c8c29c90657519a7a62b2dd4c346ce800e2b961 that fixed the issue because as I seen in https://github.com/kleisauke/net-vips/issues/90, without -Bsymbolic-functions
we may use the Unity's glib.
In my Ubuntu I have /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0.5600.4
. So probably there was an issue allocating memory from that place.
A project stopped working in my Linux PC after upgrading sharp from
0.25.4
to0.26.0
It's still crashing using0.26.1
It looks linked to the file permissions of libraries used by
vendor/8.10.0/libvips.so
but the current error handling ofsharp
isn't giving enough information. Here I describe a simplified project to reproduce the issue:Simplified project
- Start from an empty project in Linux (not nodejs/npm/node-gyp/g++/python, verify with commands like `whereis node-gyp`) - Remove `~/,cache` `~/.npm` - Install g++ 7.5.0, python 2.7.17 and python 3.6.9 - Download npm in a folder `folderName` from https://nodejs.org/en/ - Install npm@6.14.8 `sudo folderName/bin/npm i npm@6.14.8 -g` - With the new npm, install yarn@1.22.10 n@6.7.0 globally - Install the last stable version of nodejs `sudo n stable` (12.18.4 in my pc) - In a new folder, write this project: - package.json (see below) - main.js (see below) - foo.c (see below) - `yarn install` - `node main.js` (it should end normally but it's crashing, using `sudo` it's working but it shouldn't be needed) Using breakpoints in `sharp` I see that it fails also with `require("./node_modules/sharp/build/Release/sharp.node");` Using breakpoints in `require` I see that it fails aso with `process.dlopen({ exports: {} }, "/home/daniel/360/simplified_case_sharp/node_modules/sharp/build/Release/sharp.node");` Purpose of `foo.c` is to investigate why `dlopen` is crashing opening the dynamic library `sharp.node` - `gcc -o foo -g foo.c -ldl && ./foo` is returning the `error.log` (see below). I consider it weird because of the next two steps - Go to `node_modules/sharp` and we run `npm run install` - Go to previous folder, and run previous command `gcc -o foo -g foo.c -ldl && ./foo`. It's crashing but it shouldn't. Using gdb I see the `backtrace.log` (see below).package.json
```json { "name": "untitled", "version": "1.0.0", "private": true, "license": "UNLICENSED", "dependencies": { "sharp": "^0.26.1" } } ```main.js
```javascript require("sharp"); ```foo.c
```c #includeerror.log
``` error: ./node_modules/sharp/build/Release/sharp.node: undefined symbol: napi_create_error ```backtrace.log
``` (gdb) bt #0 0x0000000000000000 in ?? () #1 0x00007ffff660af77 in _g_param_type_init () from /home/daniel/360/simplified_case_sharp/./node_modules/sharp/build/Release/../../vendor/8.10.0/lib/libvips.so.42 #2 0x00007ffff5dcd222 in ?? () from /home/daniel/360/simplified_case_sharp/./node_modules/sharp/build/Release/../../vendor/8.10.0/lib/libvips.so.42 #3 0x00007ffff7de5783 in call_init (env=0x7fffffffde88, argv=0x7fffffffde78, argc=1, l=The need of
sudo node main.js
suggest issues with file permissions. Thebacktrace.log
suggests that it'slibvips.so.42
that is crashing.Questions
error.log
, could you explain it?foo.c
, could you give me hints to investigate further?Output of running
npx envinfo --binaries --system
?