sass / node-sass

:rainbow: Node.js bindings to libsass
https://npmjs.org/package/node-sass
MIT License
8.51k stars 1.32k forks source link

Segmentation fault with Webpack & node sass #1464

Closed robcalcroft closed 8 years ago

robcalcroft commented 8 years ago

Same issue as https://github.com/webpack/webpack/issues/2371, not sure if this is a 3.5.2 issue or not?

robcalcroft commented 8 years ago

Tested w/ 3.4.2 and works fine

xzyfer commented 8 years ago

@robcalcroft please confirm your segfault still happens with node-sass@v3.5.3

steadweb commented 8 years ago

3.5.3 doesn't fix the segfault issue.

xzyfer commented 8 years ago

@steadweb can you please create a small github repo that reproduce this issue so I debug it locally?

charlesdg commented 8 years ago

Same problem, came back to 3.4.2 works fine

lynxluna commented 8 years ago

Gonna vote for this one. I build by software with docker, and the webpack fails with segfault. I'm trying to go back to 3.4.2.

xzyfer commented 8 years ago

These comments are not helpful. Saying "I have a problem" does not give me any information I can use to fix this problem.

The only way to progress this issue is to create a small github repo that produces this error so I can debug it and create a patch. Help me help you.

liamkeaton commented 8 years ago

Seems to be issue with libsass https://github.com/sass/libsass/issues/2017

I am using grunt-sass so had to created a fork and roll back to node-sass 3.4.2 https://github.com/liamkeaton/grunt-sass

Stanton commented 8 years ago

@liamkeaton Grunt-sass caused my issue also, explicitly defining node-sass as a dep at 3.4.2 worked and meant I didn't need to fork. https://github.com/jadu/pulsar/pull/167/files

@xzyfer I don't have time right now to try track down the specific sass throwing the seg fault but I'll see if I can pinpoint it this evening/tomorrow.

liamkeaton commented 8 years ago

@Stanton awesome, didn't realise that would work!

travm commented 8 years ago

@Stanton @liamkeaton I don't believe that works if you do a clean npm install. I'm still getting the later version from the package that depends on it.

Stanton commented 8 years ago

@travm from my tests earlier today I'm pretty sure it works if you use '3.4.2' and not '^3.4.2'

liamkeaton commented 8 years ago

@travm it has also worked for me from a clean install using '3.4.2'

tazeverywhere commented 8 years ago

@Stanton thanks works perfectly

scasagrande-d2l commented 8 years ago

+1, getting seg faults with latest 3.5.x node-sass. Switched package.json to ~3.4.2 and thing are working again.

vmrodriguez90 commented 8 years ago

Error in 3.5.* version, i changed to the 3.4.2 and worked well, my problem is that i can't use any Mixin, or Include of SCSS

briananderson1222 commented 8 years ago

if it helps at all the root of the 'Backtrace' that gets printed out stems from this in our error logs:

at options.error (PROJECT_PATH/node_modules/node-sass/lib/index.js:274:32)

If I have more time I will try to get a basic example up..

EDIT: Also, we do not use grunt-sass.. just thought that might be a useful tidbit since everyone seems to be chiming in with that..

dfitzhenry commented 8 years ago

Seeing this via grunt-sass - confirmed to break on osx with node 5.10, centos running jenkins, and debian linux via docker... had to fork and change the node-sass version because grunt-sass is using the ^ for versions...

jglamine commented 8 years ago

I'm also seeing this when building materialize-css with webpack.

I was able to track it down to this line of sass: https://github.com/Dogfalo/materialize/blob/v0.97.5/sass/components/_buttons.scss#L169

Removing that line (or downgrading node-sass versions) fixed the issue.

mgreter commented 8 years ago

Everbody: without a self contained sample that you can confirm segfaults we cannot do much here. :exclamation: Everything else is not helping us to understand the problem :exclamation: Somebody needs to take the time to strip down his case to the bare minimum that shows us the problem. Means to remove stuff until no more stuff can be removed (and it is still segfaulting), getting rid of all imports (inline all code), etc. etc. - takes some time but is not really that hard to do!

steadweb commented 8 years ago

Trouble is @mgreter it isn't as simple as writing a "self contained sample" when really basic examples work as expected. The application that I work on has many other dependencies and the scss compilation isn't small. I understand you guys need testing steps in order to replicate, but to have that to hand and know where the problems lies may take some time.

Stanton commented 8 years ago

I'm trying to put together a small example, but not having much luck yet.

I have, however, isolated a single @import in our Sass files which, when removed, results in successful compilation. Early signs point to some combination of nested imports, extends and/or mixins which I'll try and replicate in a clean repo, but I'm not sure when that will be.

The line in question for me: https://github.com/jadu/pulsar/blob/develop/stylesheets/_component.remove-button.scss#L2

Which extends: https://github.com/jadu/pulsar/blob/develop/stylesheets/_component.buttons.scss#L202

Which imports mixins and functions from: https://github.com/jadu/pulsar/blob/develop/stylesheets/_mixin.mixins-to-organise.scss https://github.com/jadu/pulsar/blob/develop/stylesheets/_function.color.scss

I appreciate that this may not be useful information on it's own, but these notes will come in handy for myself at least.

mgreter commented 8 years ago

I can only further suggest to also check your code base with official ruby sass and also sassc (or any other binding that links to libsass with the same version). Then we would at least know if the segfault happens in libsass or node-sass binding. I also wonder if your code base produces an error in ruby sass and your seeing a variant of https://github.com/sass/libsass/issues/1962 in combination of https://github.com/sass/node-sass/issues/1457.

prashcr commented 8 years ago

@mgreter I can confirm that the issue is probably is either in libsass or node-sass. Official ruby sass works fine, node-sass segfaults.

Command I ran:

$ sass main.scss out.css
$ node-sass main.scss out.css

main.scss

@charset "UTF-8";

.mcss {
    @import 'materialize';
}

Where _materialize.scss is the SCSS entry point for the Materialize framework, which itself is just a bunch of imports. (I removed @charset "UTF-8"; from _materialize.scss since main.scss already includes it)

dfitzhenry commented 8 years ago

Here you go, @mgreter, tested this as @prashcr stated, and it segfaults -

  1. package.json (npm start): { "name": "node-sass-breakage", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "start": "node-sass sassfile.scss output.css" }, "author": "", "license": "ISC", "dependencies": { "materialize-css": "0.97.6", "node-sass": "3.5.3" } }
  2. unzip the node_modules/materialize-css/bin/materialize-src-v0.97.6.zip
  3. sassfile.scss @charset "UTF-8"; @import 'node_modules/materialize-css/bin/materialize-src/sass/materialize';
mitchhentges commented 8 years ago

Is that really a minimal test case? It pulls in all of the sass of materialize, which is a lot of content for the node-sass developers to find the issue in. My 2c, but you're the guy who put in the effort to make the minimal test case. So, thanks, too!

dfitzhenry commented 8 years ago

Great point, but I tried to put a minimal version with 2 or 3 imports, and it worked fine... seems to be an issue with bigger projects.

mgreter commented 8 years ago

At least it's straight forward to setup and the first one to actually post something we can try ourself without too much guessing on our part. I can confirm the segfault and incidentally it is already fixed on master -> https://github.com/sass/libsass/pull/2022. So this will be fixed in next versions.

mgreter commented 8 years ago

I guess node-sass keeps issues open until libsass is updated ...

On another note: It looks like materialize was never fully libsass compatible (it was silently dropping some :not() selectors). It now produces invalid css, which is IMHO better as it should be more obvious to FE devs that libsass is not doing exactly the right thing! I consider silently producing wrong results in regard to official ruby sass a bad thing.

xzyfer commented 8 years ago

The segfault with materialize-css has been fixed in v3.6.0. I'll publish it as stable in 48hrs after my weekend. Until then you can install is by specifying the version manually.

npm install node-sass@^3.6.0

or in your package.json

"node-sass": "^3.6.0",
xzyfer commented 8 years ago

node-sass@3.6.0 was released today which fixes the segfault with normalize-css

xieranmaya commented 8 years ago

The below code will still cause node-sass@3.8.0 to encounter this error

Notice the syntax error in line 2

ul.menu {
  width: 
  li {
    margin: 5px auto;
    a {
      color: #333;
    }
  }
}

Screenshot:

xieran@xieran-PC MINGW64 /d/Playground/micloud-pc/app/modules/icons (master)
$ cat a.scss
ul.menu {
  width:
  li {
    margin: 5px auto;
    a {
      color: #333;
    }
  }
}

xieran@xieran-PC MINGW64 /d/Playground/micloud-pc/app/modules/icons (master)
$ node-sass a.scss
/c/Users/xieran/AppData/Roaming/npm/node-sass: line 14:  3924 Segmentation fault      node "$basedir/node_modules/node-s
ass/bin/node-sass" "$@"

xieran@xieran-PC MINGW64 /d/Playground/micloud-pc/app/modules/icons (master)
$ node-sass -v
node-sass       3.8.0   (Wrapper)       [JavaScript]
libsass         3.3.6   (Sass Compiler) [C/C++]

xieran@xieran-PC MINGW64 /d/Playground/micloud-pc/app/modules/icons (master)
$ node -v
v6.2.2
mgreter commented 8 years ago

@xieranmaya this seems unrelated to this issue and you may want to open a new ticket for that. Just checked perl-libsass bindings, and it shows the correct error without a segfault.

xieranmaya commented 8 years ago

@mgreter so it seems a bug of node-sass or node?

xzyfer commented 8 years ago

@xieranmaya you can see that the code supplied errors as expected with the latest node-sass on sassmeister.

There appears be an environmental issue. I suggest cleaning your local environment

rm -rf node_modules
npm cache clean

After a fresh npm install, if you're still experiencing issues please provide the output the following commands

npm -v              
node -v
node -p process.versions
node -p process.platform
node -p process.arch
.\node_modules\.bin\node-sass --version
node -p "console.log(require('node-sass').info)"
dir node_modules\node-sass\vendor
calbertts commented 7 years ago

I'm getting this message: Segmentation fault just after sass started.

I'm using a docker container with Alpine, this is my ouput:

$ 4.0.5 $ v7.4.0 $ { http_parser: '2.7.0', node: '7.4.0', v8: '5.4.500.45', uv: '1.10.1', zlib: '1.2.8', ares: '1.10.1-DEV', modules: '51', openssl: '1.0.2j', icu: '58.2', unicode: '9.0', cldr: '30.0.3', tz: '2016j' } $ linux $ x64 $ node-sass 3.10.1 (Wrapper) [JavaScript] libsass 3.3.6 (Sass Compiler) [C/C++] $ node-sass 3.10.1 (Wrapper) [JavaScript] libsass 3.3.6 (Sass Compiler) [C/C++] undefined $ linux-x64-51

xzyfer commented 7 years ago

@calbertts your issue is unrelated. Alpine support was only added in node-sass@v4.1.0

torvitas commented 7 years ago

Hi, we are still seeing a seg-fault.

os: alpine (node:8-alpine docker image) node: 8 npm: 5 webpack 3.0.0 (its the same issue with 2.6) node-sass: 4.5.3

It works if we use very simple sass.

xzyfer commented 7 years ago

@torvitas see #2031 for alpine issues

fdbeirao commented 6 years ago

@torvitas I was having this segmentation fault just now, and I was based on an alpine 3.6 docker image.

I "just" changed my Dockerfile to start FROM alpine:3.7 and the segmentation fault went away.