node-sass icon indicating copy to clipboard operation
node-sass copied to clipboard

Segmentation fault on Node 8 alpine (docker)

Open ForsakenHarmony opened this issue 9 years ago • 48 comments

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 [email protected]                                                                                            
npm info using [email protected]                                                                                          
npm info lifecycle [email protected]~prewebpack: [email protected]                                                      
npm info lifecycle [email protected]~webpack: [email protected]                                                         
                                                                                                                    
> [email protected] 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 [email protected]~webpack: Failed to exec webpack script                                           
npm ERR! code ELIFECYCLE                                                                                            
npm ERR! errno 139                                                                                                  
npm ERR! [email protected] webpack: `webpack --progress --colors --config webpack.config.js`                          
npm ERR! Exit status 139                                                                                            
npm ERR!                                                                                                            
npm ERR! Failed at the [email protected] 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++]

ForsakenHarmony avatar Jun 27 '17 21:06 ForsakenHarmony

Can you add the log to a Gist? I'm not seeing anything in the current output, besides that it failed around a Sass file, that indicates this is a node-sass issue.

I'd also suggest just trying to reproduce it without webpack

nschonni avatar Jun 27 '17 21:06 nschonni

https://gist.github.com/ForsakenHarmony/3ddcfcab7e932a5a6a48094eda7854c7

I'm not quite sure what's going on, it only seems to happen in the docker build script, not if I run it inside the container

may also be my code, because this doesn't crash

FROM node:8-alpine

RUN mkdir -p /usr/app
WORKDIR /usr/app

RUN yarn add node-sass
ENV NODE_ENV production
RUN node -e "require('node-sass').renderSync({data: '* {height: 2px}'});"

ForsakenHarmony avatar Jun 28 '17 11:06 ForsakenHarmony

It does not seem to crash. Looks like a permission problem, people usually run as root inside a container, check our troubleshooting guide for info on unsafe permissions

saper avatar Jun 28 '17 19:06 saper

Segmentation fault is a type of crash to me

ForsakenHarmony avatar Jun 28 '17 20:06 ForsakenHarmony

I am sorry, didn't scroll that far right. Can you try to get the core file?

saper avatar Jun 28 '17 20:06 saper

Quick question, are project files copied from Debian?

saper avatar Jun 28 '17 20:06 saper

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.

xzyfer avatar Jun 30 '17 01:06 xzyfer

@saper the core file? also yes, copied from debian node_modules doesn't get copied ( doesn't exist ) I get the feeling it's the build itself

ForsakenHarmony avatar Jun 30 '17 16:06 ForsakenHarmony

probably your binding.node is copied/cached from Debian, this way it has to crash.

saper avatar Jun 30 '17 21:06 saper

it also happens in ci

ForsakenHarmony avatar Jun 30 '17 21:06 ForsakenHarmony

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).

mikestead avatar Jul 02 '17 05:07 mikestead

Between 6 and 8, the node images changed from Alpine 3.4 to 3.6 so there may be some difference there. We did use their image to build our binaries though

nschonni avatar Jul 03 '17 01:07 nschonni

@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?

xzyfer avatar Jul 03 '17 01:07 xzyfer

tried rebuilding in the Dockerfile, didn't change anything

ForsakenHarmony avatar Jul 03 '17 18:07 ForsakenHarmony

@ForsakenHarmony thanks. If a fresh local recompiled binary is still segfaulting I'm not sure what we can do. This could be an issue with Node 8 or Nan.

xzyfer avatar Jul 04 '17 01:07 xzyfer

FWIW I'm seeing something similar but nothing to do with node-sass.

I've had a node application running FROM node:8-alpine for a while now with no problems. I've been toying with using babel-preset-env to transpile code in a version-aware manner. Presumably this means that more of my code is now using native ES features that are available in node 8 features rather than transpiled ES5 code.

Anyway, something has changed and the app crashes with Segmentation Fault when I try to log in (works fine up until this point). Switching the Dockerfile back to FROM node:8 fixes the issue.

djskinner avatar Jul 07 '17 15:07 djskinner

https://gist.github.com/ForsakenHarmony/7efb3659dac985a90598b869b07c7e46

this is the dockerfile I tested with, project is linked in the main post

ForsakenHarmony avatar Jul 07 '17 17:07 ForsakenHarmony

I am experiencing the same problem with a switch from Node 6 to 8.1.4 (alpine-based images).

Edit: I can confirm that not using an alpine-based image solves the problem (at least my problem).

willdurand avatar Jul 13 '17 15:07 willdurand

Can anyone provide a backtrace for this?

saper avatar Jul 13 '17 23:07 saper

I could not reproduce this bug on this example but in my case it happen too. This is a trace from my app https://gist.github.com/pawelpalka81/b6899c60551f7db20376b5e330aa1702

pawelpalka81 avatar Jul 18 '17 10:07 pawelpalka81