node-sass: Segmentation fault on Node 8 alpine (docker)

Works with node 6 and on my host machine ( debian, node 8 )

this is my project, can also try to make a smaller testcase if required https://github.com/ForsakenHarmony/portfolio

yarn build v0.24.6                                                                                                  
$ cross-env NODE_ENV=production npm run webpack                                                                     
npm info it worked if it ends with ok                                                                               
npm info using npm@5.0.3                                                                                            
npm info using node@v8.1.2                                                                                          
npm info lifecycle portfolio@0.1.0~prewebpack: portfolio@0.1.0                                                      
npm info lifecycle portfolio@0.1.0~webpack: portfolio@0.1.0                                                         
                                                                                                                    
> portfolio@0.1.0 webpack /usr/src/app                                                                              
> webpack --progress --colors --config webpack.config.js                                                            
                                                                                                                    
 12% building modules 20/21 modules 1 active ...!/usr/src/app/client/styles/main.scssSegmentation fault (core dumped
)                                                                                                                   
npm info lifecycle portfolio@0.1.0~webpack: Failed to exec webpack script                                           
npm ERR! code ELIFECYCLE                                                                                            
npm ERR! errno 139                                                                                                  
npm ERR! portfolio@0.1.0 webpack: `webpack --progress --colors --config webpack.config.js`                          
npm ERR! Exit status 139                                                                                            
npm ERR!                                                                                                            
npm ERR! Failed at the portfolio@0.1.0 webpack script.                                                              
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.                  
                                                                                                                    
npm ERR! A complete log of this run can be found in:                                                                
npm ERR!     /root/.npm/_logs/2017-06-26T22_44_11_188Z-debug.log                                                    
error Command failed with exit code 139.                                                                            
Removing intermediate container 5cb53913df5e
  • NPM version (npm -v): 5.0.3
  • Node version (node -v): v8.1.2
  • Node Process (node -p process.versions): { http_parser: ‘2.7.0’, node: ‘8.1.2’, v8: ‘5.8.283.41’, uv: ‘1.12.0’, zlib: ‘1.2.11’, ares: ‘1.10.1-DEV’, modules: ‘57’, openssl: ‘1.0.2l’, icu: ‘59.1’, unicode: ‘9.0’, cldr: ‘31.0.1’, tz: ‘2017b’ }
  • Node Platform (node -p process.platform): linux
  • Node architecture (node -p process.arch): x64
  • node-sass version (node -p "require('node-sass').info"): node-sass 4.5.3 (Wrapper) [JavaScript] libsass 3.5.0.beta.2 (Sass Compiler) [C/C++]

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 31
  • Comments: 48 (18 by maintainers)

Commits related to this issue

Most upvoted comments

Segmentation fault is a type of crash to me

Here is my workaround for the issue, and the image is top20/node:8-alpine.

@saper guess I should stop using sass then

This is great @enko. I think the root cause of the problem is http://wiki.musl-libc.org/wiki/Functional_differences_from_glibc#Thread_stack_size

If that is confirmed, there is not much we can do about it.

See for example discussion https://github.com/voidlinux/void-packages/issues/4147

I managed to procure a stacktrace! I used the node8-alpine docker image. I used the following steps to reproduce:

docker run --security-opt seccomp:unconfined --cap-add SYS_PTRACE -it node8-alpine /bin/sh
apk update && apk add git make g++ python2 gdb
cd /tmp
git clone https://github.com/sass/node-sass/
cd node-sass
yarn
node scripts/build.js --force --debug
gdb node
set args bin/node-sass node_modules/sass-spec/spec/scss/huge/input.scss
run
bt

I have attached a backtrace that I got:

Stacktrace

@jubel-han Thanks! Your workaround worked for me

I was facing the same problem serving an express server. For some reason -alpine version throw segmentation fault.

Using just node:8 solved my problem

using node:10.13-alpine seems to solve the problem

Different kind of fix could possibly be the following addition in your Dockerfiles. Fix: https://github.com/nodejs/docker-node/issues/588

I had the same issue not using Sass. It only occurs if the docker host itself has a hardened linux kernel (alpine in my case).

@xzyfer I confirm, 4.8.3 cause Segmentation fault (core dumped). On 4.8.2 we have no problems

In a nightcourse, we were asked to setup a node http server in docker.

I looked up what was good for docker and found it was alpine linux so I installed that in a VM. Then I installed docker in that and then I followed a few basic tutorials to try and get node going. None worked and I kept getting the error code 139.

Example 1: Segmentation fault The command ‘/bin/sh -c npm install’ returned a non-zero code: 139

Example 2: CONTAINER ID IMAGE COMMAND CREATED STATUS 107a1b769d33 webapp “node index.js” 9 seconds ago Exited (139)

I searched for a very long time and eventually I found this thread and saw the reply from @cw789 which helped. It did not explain what I should do but I pieced it together from looking at the solution and how some others patched their systems.

The fix is for me to add this to my Dockerfile before npm gets called:

RUN apt-get update -y && apt-get dist-upgrade -y && \
apt-get install -y --no-install-recommends paxctl && \
paxctl -mC `which node`

It also works if I add it just after: FROM node:carbon

If this comment seems long and includes a lot of technical lines, it is meant to. If anyone else ends up googling the errors like I did, I hope this helps.

You’ll need to delete your node_modules and reinstall your modules inside the container. Copying files from (or reusing a cache) between debian and alpine is going to result in segfaults.

@mikestead can you run npm rebuild node-sass --force within the Node 8.1 container and confirm whether the segfault is still present?

Also can you supply a minimal scss code sample the produces the segfault so we can investigate further?

Having exact same issue. Fails with segmentation fault after a clean build and run inside Alpine image based on this Dockerfile (Node 8.1 + build essentials).

Works fine when doing the same thing inside image from this Dockerfile (Node 6.11 + build essentials).

it also happens in ci

same here with node8 and node-sass 4.5.3 with clean node:alpine

Quick question, are project files copied from Debian?