Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault with Webpack & node sass #1464

Closed
robcalcroft opened this issue Apr 21, 2016 · 40 comments
Closed

Segmentation fault with Webpack & node sass #1464

robcalcroft opened this issue Apr 21, 2016 · 40 comments

Comments

@robcalcroft
Copy link

Same issue as webpack/webpack#2371, not sure if this is a 3.5.2 issue or not?

@robcalcroft
Copy link
Author

robcalcroft commented Apr 21, 2016

Tested w/ 3.4.2 and works fine

@xzyfer
Copy link
Contributor

xzyfer commented Apr 21, 2016

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

@steadweb
Copy link

3.5.3 doesn't fix the segfault issue.

@xzyfer
Copy link
Contributor

xzyfer commented Apr 21, 2016

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

@charlesdg
Copy link

Same problem, came back to 3.4.2 works fine

@lynxluna
Copy link

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
Copy link
Contributor

xzyfer commented Apr 21, 2016

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
Copy link

liamkeaton commented Apr 21, 2016

Seems to be issue with libsass sass/libsass#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
Copy link

Stanton commented Apr 21, 2016

@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
Copy link

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

@travm
Copy link

travm commented Apr 21, 2016

@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
Copy link

Stanton commented Apr 21, 2016

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

@liamkeaton
Copy link

liamkeaton commented Apr 21, 2016

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

@tazeverywhere
Copy link

@Stanton thanks works perfectly

@scasagrande-d2l
Copy link

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

@vmrodriguez90
Copy link

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
Copy link

briananderson1222 commented Apr 21, 2016

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
Copy link

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
Copy link

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
Copy link
Contributor

mgreter commented Apr 21, 2016

Everbody: without a self contained sample that you can confirm segfaults we cannot do much here.
Everything else is not helping us to understand the problem
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
Copy link

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
Copy link

Stanton commented Apr 21, 2016

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
Copy link
Contributor

mgreter commented Apr 21, 2016

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 sass/libsass#1962 in combination of #1457.

@prashcr
Copy link

prashcr commented Apr 22, 2016

@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
Copy link

dfitzhenry commented Apr 22, 2016

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
Copy link

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
Copy link

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
Copy link
Contributor

mgreter commented Apr 22, 2016

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 -> sass/libsass#2022. So this will be fixed in next versions.

@mgreter
Copy link
Contributor

mgreter commented Apr 22, 2016

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
Copy link
Contributor

xzyfer commented Apr 23, 2016

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
Copy link
Contributor

xzyfer commented Apr 26, 2016

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

@xieranmaya
Copy link

xieranmaya commented Jun 24, 2016

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
Copy link
Contributor

mgreter commented Jun 24, 2016

@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
Copy link

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

@xzyfer
Copy link
Contributor

xzyfer commented Jun 29, 2016

@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

@xzyfer xzyfer modified the milestone: next.libsass Sep 4, 2016
@calbertts
Copy link

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
Copy link
Contributor

xzyfer commented Jan 26, 2017

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

@torvitas
Copy link

torvitas commented Jun 29, 2017

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
Copy link
Contributor

xzyfer commented Jun 30, 2017

@torvitas see #2031 for alpine issues

@fdbeirao
Copy link

fdbeirao commented Dec 7, 2017

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

jiongle1 pushed a commit to scantist-ossops-m2/node-sass that referenced this issue Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests