melchor629 / node-flac-bindings

Nodejs bindings to libFLAC
ISC License
17 stars 1 forks source link

Illegal instruction (Core dumped) error on Synology DS718+ #32

Closed cerbaire closed 2 years ago

cerbaire commented 2 years ago

Hello, I created a new docker image of my application and deployed it on my NAS. The container failed to start. After investigation, I found that the problem is when loading flac-bindings.node. I think it is the first time I build my image on a Intel MacOS to deploy in it on my Intel NAS, so maybe the bad version of flac-bindings.node is downloaded when creating the docker image. So I uninstalled and reinstalled flac-bindings package in the container, but is does not solve the problem. I don't find trace of what version of the binary is downloaded when running npm install. I tried with node 10, 12, 14 and 16 without success.

Any clue on why I can't get the good version of the binary for my NAS ? Or how I can solve the problem ? Thanks for your support.

melchor629 commented 2 years ago

Hi, you can start with using the DEBUG environment variable. During installation if you use DEBUG=flac:build (or just DEBUG=flac:*) you should get some insights of what is doing internally. But the download is made by prebuild-install (if there is a binary compatible) so, I recommend to also set the npm log level to verbose during the install to see the logs from that package (see https://docs.npmjs.com/cli/v8/using-npm/config). Just to setup it up quickly, defining the environment variable npm_config_loglevel=verbose should work.

On the other hand, don't know how are you building the docker image but as a recommendation, you should only copy the sources and the package.json and package-lock.json into the Dockerfile and then run npm install (and whatever other steps you require). This way you ensure that the environment inside the image is "as pure as it can" (?).

First try getting the logs out and if you find something just post it here. If not, you can put logs here (or in a gist/pastebin/whatever).

Also, which version of the package are you using? (latest I guess, just to confirm) Which is your base image in docker? (node? some debian?)

Happy christmas btw :)

cerbaire commented 2 years ago

Thanks for your quick response. I will have a look at it after Christmas. I am using a 2 steps build, one with source to build js, and one with package.json and package-lock.json to install dependencies along with the build results. It was working until last time I deployed the image in July. But since that time I use a Mac instead of a PC to develop. Note that the application works great when running in docker on the Mac. Happy Christmas

melchor629 commented 2 years ago

Well, maybe you don't need to do anything. I checked with a friend that has a modern CPU than yours on the Synology but is a Celeron and he also gets the same issue. I found what is causing the issue (the code is not suposed to generate AVX instructions but it is doing it now so, and those CPUs do not support AVX). So I have to rebuild those packages without AVX instructions.

I'll update the issue when I made those changes and ensured it is working.

Happy Christmas!

melchor629 commented 2 years ago

I updated 2.7.0 binaries for GNU/Linux with the correct compiler flags, it should work in your Synology now. When possible, answer here if this fixes. To ensure to pick the right version, build the image without cache.

Thanks for the issue and Happy Christmas (once again)!!

cerbaire commented 2 years ago

Hi and Happy new year, I have tried many times but I cannot get it to work. I have also run manually a container within a SSH session on my NAS and reinstall the dependencies without any luck.

melchor629 commented 2 years ago

Hi again,

Just double-checked if something is missing (in the friend's computer) and it is loading properly without crashes. As you are trying to reinstall the dependencies, check out this path $HOME/.npm/_prebuilds. This is where prebuild stores the packages as cache. Maybe prebuild is always getting the compiled binary from there instead of downloading again from github. Give it a try and let me know if it works!

cerbaire commented 2 years ago

Hi! I have removed the suggested folder and tried again:

bash-5.1$ node server.js ... MODULE 89: load "/home/node/app/node_modules/flac-bindings/build/Release/flac-bindings.node" for module "/home/node/app/node_modules/flac-bindings/build/Release/flac-bindings.node" Illegal instruction (core dumped)

bash-5.1$ ls -l /home/node/.npm/_prebuilds/ total 632 -rw-r--r-- 1 node 1000 643382 Jan 11 22:56 6a2f74-flac-bindings-v2.7.0-napi-v8-linuxmusl-x64.tar.gz bash-5.1$

melchor629 commented 2 years ago

Oh, it's Alpine. I should have asked this before...

I think I forget to update those binaries as well...

Because I don't remember and cannot test those binaries, I will recompile and upload them again. Just in case.

I will have them by tomorrow (to avoid ambiguity let's say around 23h-00h UTC). Do the same steps again (remove prebuild cache, reinstall dependencies, etc.).

Really sorry for the inconvenience :(

Edit: they are already uploaded

cerbaire commented 2 years ago

yeah! It works. You've got it. Many thanks for your great support.

melchor629 commented 2 years ago

Oh really cool :)

Again, sorry for forgetting to update the Alpine ones, but you now have this working so YAY 🎉

Thanks for raising the issue. Don't hesitate to raise another issue if you find something else broken.