Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Illegal instruction: 4 and Bus error: 10 #1289

Closed
58bits opened this issue Nov 30, 2015 · 42 comments
Closed

Illegal instruction: 4 and Bus error: 10 #1289

58bits opened this issue Nov 30, 2015 · 42 comments
Assignees
Labels

Comments

@58bits
Copy link

58bits commented Nov 30, 2015

I have the following error using node-sass (whether from the command line, or via the Grunt plugin).

  1. When using a project local installed node-sass module...
node-sass --output-style expanded ./scss/test.scss ./scss/test.css
Bus error: 10
  1. When using a globally installed node-sass
node-sass --output-style expanded ./scss/test.scss ./scss/test.css
Illegal instruction: 4
  1. The stylesheet is successfully compiled when using https://github.com/sass/sassc and a locally installed and compiled version of libsass (https://github.com/sass/sassc/blob/master/docs/building/unix-instructions.md)
sassc ./scss/test.scss ./scss/test.css

The entire issue and source stylesheet is documented here at at-import/Singularity#215 and here at SassMeister http://sassmeister.com/gist/ac31969a3b5dfcbef1a5 (SassMeister also compiles the stylesheet fine).

The problem occurs when using the Singularity grid system in debug mode, and setting a background-grid color, and apparently only on Mac OS X. The grid system generates some large string inline embedded svg images for the background grid.

Here are a few platform details.

node-sass --version
node-sass   3.4.2   (Wrapper)   [JavaScript]
libsass     3.3.2   (Sass Compiler) [C/C++]
OS X El Capitan Version 10.11.1 (15B42)
Node v5.1.0

Any suggestions or ideas out there?

For interest, here's what the successfully compiled sass stylesheet produces...

https://gist.github.com/58bits/bd225aa29e4c89e2e2c2

@58bits
Copy link
Author

58bits commented Nov 30, 2015

The problem seems to be causes by the large data:image/svg+xml inline strings in

If the inline svg string is less than about 1,558 bytes - node-sass compiles fine.

If the inline svg string is about 1,673 bytes or greater - the error is generated.

It doesn't matter how many inline svg strings there are - as long as no single inline svg embed goes over roughly 1,558 bytes.

(I can only adjust the number of grids, which determines the number of columns in the svg element, and so I can't tell you where the exact byte cutoff is).

@xzyfer
Copy link
Contributor

xzyfer commented Nov 30, 2015

Thanks for your investigation @58bits.

Could you please supply a sassmeister of broken (long) data url and working one. Having the single line of CSS causing the issue will help us quickly identify the problem as opposed to digging through a framework.

@58bits
Copy link
Author

58bits commented Nov 30, 2015

Hi - here's a simple gist which generates the error locally... (Illegal instruction: 4)

http://sassmeister.com/gist/6c5443acf20fe855f854

And here's what the output 'should' look like (in this case compiled with sassc - and of course also in the CSS of the SassMeister gist as well.)

https://gist.github.com/58bits/d9475778075bae440c60

If @include add-grid(8); is changes to @include add-grid(7); - the resulting inline svg is then a few hundred bytes smaller, and node-sass will compile this scss fine.

@xzyfer
Copy link
Contributor

xzyfer commented Nov 30, 2015

I don't have an environment for singularity locally atm. Can you confirm whether the issue happens your input scss is the output css?

This will confirm whether the issue is due to the length of the string or the code that generates the string is problematic.

@58bits
Copy link
Author

58bits commented Nov 30, 2015

Hi @xzyfer thanks for the quick replies. Taking the outputed css from sassc and feeding that back into node-scss - doesn't generate the error. :-(

@xzyfer
Copy link
Contributor

xzyfer commented Nov 30, 2015

That's interesting. I guess we'll need to dig into singularity itself. Maybe @Snugug can point in the right direction for potential causes.

@58bits
Copy link
Author

58bits commented Nov 30, 2015

Understood - although strange that https://github.com/sass/sassc is able to compile the sass stylesheet fine. Maybe a combination of Node.js, V8, and Singularity? Is there some intermediate value that's causing the problem?

@58bits
Copy link
Author

58bits commented Nov 30, 2015

I wonder what Seissmaster is using as their interface to Libsass - since it compiles fine with them.

@xzyfer
Copy link
Contributor

xzyfer commented Nov 30, 2015

Sassmeister uses node-sass, but they're using an older version that's compiled against LibSass 3.2.5.

screen shot 2015-11-30 at 6 15 29 pm

@xzyfer
Copy link
Contributor

xzyfer commented Nov 30, 2015

It could be an issue with the C++ code in node-sass that talks to LibSass.

@xzyfer
Copy link
Contributor

xzyfer commented Nov 30, 2015

It would be useful to know if this happens on different versions of node,
and/or different versions of node sass. If you could find the version,
between 3.3.0 and 3.4.2, where this started happening that would be useful.
On 30 Nov 2015 5:18 pm, "Anthony Bouch" notifications@github.com wrote:

I wonder what Seissmaster is using as their interface to Libsass.


Reply to this email directly or view it on GitHub
#1289 (comment).

@58bits
Copy link
Author

58bits commented Nov 30, 2015

Which version of node-sass matches the Libsass version in use use at SassMeister? I'll try that one first, and then work my way up ;-)

@58bits
Copy link
Author

58bits commented Nov 30, 2015

Or rather - I'll try that one first, and then work my way up.

@xzyfer
Copy link
Contributor

xzyfer commented Nov 30, 2015

v3.2.0

@58bits
Copy link
Author

58bits commented Nov 30, 2015

v3.2.0 fails to install - starting with Cannot download "https://github.com/sass/node-sass/releases/download/v3.2.0/darwin-x64-47_binding.node": HTTP error 404 Not Found

...and then source compilation error:

In file included from ../src/binding.cpp:1:
../node_modules/nan/nan.h:772:12: error: no viable conversion from 'v8::MaybeLocal<v8::Object>' to 'v8::Local<v8::Object>'
    return node::Buffer::New(v8::Isolate::GetCurrent(), size);

I suspect this is due to the version of node I'm using.

I'm running out of cycles here. I'll try newer versions until I get a successful build, and then see what happens.

@58bits
Copy link
Author

58bits commented Nov 30, 2015

v3.3.0

node-sass -v
node-sass   3.3.0   (Wrapper)   [JavaScript]
libsass     3.2.5   (Sass Compiler) [C/C++]

Same error....

node-sass scss/test.scss scss/test.css
Illegal instruction: 4

@xzyfer
Copy link
Contributor

xzyfer commented Nov 30, 2015

v3.2.0 requires iojs 1, 2 or node 0.10, 0.12

@58bits
Copy link
Author

58bits commented Nov 30, 2015

Okay understood - but I'm afraid at this point I'm not sure when I'll have the time to change my dev environment, or setup a test for an earlier version of node-sass. I'm working on a single app built for Node.js 5.1 at the moment (and so I'm not using an environment switcher like N).

@Snugug
Copy link

Snugug commented Nov 30, 2015

@xzyfer @58bits I'm digging in to this.

I've got the following:

  • Node v0.12.7
  • NPM v2.11.3
  • Node Sass v3.2.0
  • Latest OSX
  • Latest ZSH
@import 'bower_components/singularity/stylesheets/singularitygs';

@include sgs-change('debug', true);

@include add-grid(8);
@include add-gutter(0);

.container {
  margin: 0 auto;
  @include background-grid($color: #CCF);
}

Error:

> bugs@1.0.0 sass /Users/samrichard/Review/bugs
> node-sass --output-style expanded ./style.scss ./style.css

[1]    14822 illegal hardware instruction  npm run sass

This is connected to SVG string building we're doing. @58bits appears to have narrowed it down to a single string of a given size (~1,558 bytes or less is fine, ~1,673 bytes or greater is not). Might this be a SO issue with the string type?

@xzyfer
Copy link
Contributor

xzyfer commented Nov 30, 2015

Thanks for all your work folk, I can reproduce this locally now.

@Snugug
Copy link

Snugug commented Nov 30, 2015

👍

@Snugug
Copy link

Snugug commented Nov 30, 2015

Thank you @xzyfer !

@58bits
Copy link
Author

58bits commented Nov 30, 2015

Thank you x2 @xzyfer! :-)

@xzyfer
Copy link
Contributor

xzyfer commented Nov 30, 2015

I've narrowed the problem down the overloaded str-replace function. A minimal test case can be found at https://gist.github.com/xzyfer/2cc0fcfc3c7c0fdc061e

@58bits
Copy link
Author

58bits commented Dec 2, 2015

Hi @xzyfer - does this mean url-encode($string) is the culprit?

@xzyfer
Copy link
Contributor

xzyfer commented Dec 3, 2015

Yes. Specifically the str-replace method that singularity defines. I haven't had time to dig into the specifics much further. I was able to confirm it doesn't happen with sassc. This suggests it may have something to do with the node-sass C++ binding code.

@saper saper added the OS - OSX label Dec 3, 2015
@saper
Copy link
Member

saper commented Dec 3, 2015

Here is what I got on FreeBSD:

node-sass   3.4.2   (Wrapper)   [JavaScript]
libsass     3.3.2+FreeBSD.f47645c   (Sass Compiler) [C/C++]
m> ~/node_modules/node-sass/bin/node-sass node-sass-bug.scss 
foo {
  bar: "%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww%2Ew3%2Eorg%2F2000%2Fsvg%22%3E%3Crect%20x%3D%220%25%22%20fill%3D%22%23CCF%22%20width%3D%2210%2E25641%25%22%20height%3D%22100%25%22%2F%3E%3Crect%20x%3D%2210%2E25641%25%22%20fill%3D%22%23d9d9ff%22%20width%3D%222%2E5641%25%22%20height%3D%22100%25%22%2F%3E%3Crect%20x%3D%2212%2E82051%25%22%20fill%3D%22%23CCF%22%20width%3D%2210%2E25641%25%22%20height%3D%22100%25%22%2F%3E%3Crect%20x%3D%2223%2E07692%25%22%20fill%3D%22%23d9d9ff%22%20width%3D%222%2E5641%25%22%20height%3D%22100%25%22%2F%3E%3Crect%20x%3D%2225%2E64103%25%22%20fill%3D%22%23CCF%22%20width%3D%2210%2E25641%25%22%20height%3D%22100%25%22%2F%3E%3Crect%20x%3D%2235%2E89744%25%22%20fill%3D%22%23d9d9ff%22%20width%3D%222%2E5641%25%22%20height%3D%22100%25%22%2F%3E%3Crect%20x%3D%2238%2E46154%25%22%20fill%3D%22%23CCF%22%20width%3D%2210%2E25641%25%22%20height%3D%22100%25%22%2F%3E%3Crect%20x%3D%2248%2E71795%25%22%20fill%3D%22%23d9d9ff%22%20width%3D%222%2E5641%25%22%20height%3D%22100%25%22%2F%3E%3Crect%20x%3D%2251%2E28205%25%22%20fill%3D%22%23CCF%22%20width%3D%2210%2E25641%25%22%20height%3D%22100%25%22%2F%3E%3Crect%20x%3D%2261%2E53846%25%22%20fill%3D%22%23d9d9ff%22%20width%3D%222%2E5641%25%22%20height%3D%22100%25%22%2F%3E%3Crect%20x%3D%2264%2E10256%25%22%20fill%3D%22%23CCF%22%20width%3D%2210%2E25641%25%22%20height%3D%22100%25%22%2F%3E%3Crect%20x%3D%2274%2E35897%25%22%20fill%3D%22%23d9d9ff%22%20width%3D%222%2E5641%25%22%20height%3D%22100%25%22%2F%3E%3Crect%20x%3D%2276%2E92308%25%22%20fill%3D%22%23CCF%22%20width%3D%2210%2E25641%25%22%20height%3D%22100%25%22%2F%3E%3Crect%20x%3D%2287%2E17949%25%22%20fill%3D%22%23d9d9ff%22%20width%3D%222%2E5641%25%22%20height%3D%22100%25%22%2F%3E%3Crect%20x%3D%2289%2E74359%25%22%20fill%3D%22%23CCF%22%20width%3D%2210%2E25641%25%22%20height%3D%22100%25%22%2F%3E%3C%2Fsvg%3E"; }

if we get it on Mac OS X only, the issue may be related to the old libc++ runtime library being used on OS X...

Would that be possible to get a debugger backtrace on that crash?

@58bits
Copy link
Author

58bits commented Dec 4, 2015

Here's what I get on Ubuntu 14.04.3 LTS (using the source test file - same SVG element - and compiles fine.).

node-sass   3.4.2   (Wrapper)   [JavaScript]
libsass     3.3.2   (Sass Compiler) [C/C++]
∴ /usr/bin/lib/node_modules/node-sass/bin/node-sass test.scss test.css
.container {
  height: 100vh;
  position: relative;
  width: 100%;
  margin: 0 auto;
  background-image: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww%2Ew3%2Eorg%2F2000%2Fsvg%22%3E%3Crect%20x%3D%220%25%22%20fill%3D%22%23338%22%20width%3D%2212%2E5%25%22%20height%3D%22100%25%22%2F%3E%3Crect%20x%3D%2212%2E5%25%22%20fill%3D%22%236666a6%22%20width%3D%220%25%22%20height%3D%22100%25%22%2F%3E%3Crect%20x%3D%2212%2E5%25%22%20fill%3D%22%232b2b74%22%20width%3D%2212%2E5%25%22%20height%3D%22100%25%22%2F%3E%3Crect%20x%3D%2225%25%22%20fill%3D%22%236666a6%22%20width%3D%220%25%22%20height%3D%22100%25%22%2F%3E%3Crect%20x%3D%2225%25%22%20fill%3D%22%23338%22%20width%3D%2212%2E5%25%22%20height%3D%22100%25%22%2F%3E%3Crect%20x%3D%2237%2E5%25%22%20fill%3D%22%236666a6%22%20width%3D%220%25%22%20height%3D%22100%25%22%2F%3E%3Crect%20x%3D%2237%2E5%25%22%20fill%3D%22%232b2b74%22%20width%3D%2212%2E5%25%22%20height%3D%22100%25%22%2F%3E%3Crect%20x%3D%2250%25%22%20fill%3D%22%236666a6%22%20width%3D%220%25%22%20height%3D%22100%25%22%2F%3E%3Crect%20x%3D%2250%25%22%20fill%3D%22%23338%22%20width%3D%2212%2E5%25%22%20height%3D%22100%25%22%2F%3E%3Crect%20x%3D%2262%2E5%25%22%20fill%3D%22%236666a6%22%20width%3D%220%25%22%20height%3D%22100%25%22%2F%3E%3Crect%20x%3D%2262%2E5%25%22%20fill%3D%22%232b2b74%22%20width%3D%2212%2E5%25%22%20height%3D%22100%25%22%2F%3E%3Crect%20x%3D%2275%25%22%20fill%3D%22%236666a6%22%20width%3D%220%25%22%20height%3D%22100%25%22%2F%3E%3Crect%20x%3D%2275%25%22%20fill%3D%22%23338%22%20width%3D%2212%2E5%25%22%20height%3D%22100%25%22%2F%3E%3Crect%20x%3D%2287%2E5%25%22%20fill%3D%22%236666a6%22%20width%3D%220%25%22%20height%3D%22100%25%22%2F%3E%3Crect%20x%3D%2287%2E5%25%22%20fill%3D%22%232b2b74%22%20width%3D%2212%2E5%25%22%20height%3D%22100%25%22%2F%3E%3C%2Fsvg%3E"); 
}

@58bits
Copy link
Author

58bits commented Dec 4, 2015

Definitely punching above my weight here, but I just tried to capture the error and a stack trace via the node-sass api calling sass.render - but even within a specific domain using a domain-based uncaught error handler, Node simply exits with Bus error: 10. There's no error object or stack trace from within Node.

@58bits
Copy link
Author

58bits commented Dec 4, 2015

Here's the output from lldb node test.js

Process 2974 stopped
* thread #6: tid = 0x8d10, 0x000000010312088c binding.node`Sass::bind(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, Sass::Parameters*, Sass::Arguments*, Sass::Context*, Sass::Environment<Sass::AST_Node*>*, Sass::Eval*) + 20, stop reason = EXC_BAD_ACCESS (code=2, address=0x700000418790)
    frame #0: 0x000000010312088c binding.node`Sass::bind(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, Sass::Parameters*, Sass::Arguments*, Sass::Context*, Sass::Environment<Sass::AST_Node*>*, Sass::Eval*) + 20
binding.node`Sass::bind:
->  0x10312088c <+20>: movq   %r9, -0x10c0(%rbp)
    0x103120893 <+27>: movq   %r8, -0x10f0(%rbp)
    0x10312089a <+34>: movq   %rcx, %r14
    0x10312089d <+37>: movq   %rdx, %r13

@saper
Copy link
Member

saper commented Jan 3, 2016

It might be that we are getting a stack overflow here. I'd need values of the stack registers at the time of the crash, this is register read from lldb or info registers from gdb.

@saper
Copy link
Member

saper commented Jan 3, 2016

More background infromation: https://developer.apple.com/library/mac/qa/qa1419/_index.htm
so we might be "limited" 512 kilobytes of stack when we launch a libsass thread.

@xzyfer does it also fail when running via sassc (the default stack size should be is larger there). If it does not fail, does increasing the SVG file size make it crash?

@saper
Copy link
Member

saper commented Jan 3, 2016

Also, a full backtrace would be good. (bt command from the debugger). The function where the failure occurs needs "only" 4 kilobytes on stack.

@saper saper self-assigned this Jan 3, 2016
@saper
Copy link
Member

saper commented Jan 3, 2016

I can reproduce this locally now by limiting my stack size to 512 kilobytes.

@saper
Copy link
Member

saper commented Jan 3, 2016

@xzyfer can you produce a backtrace (bt, info registers/registers read) when running https://gist.github.com/xzyfer/2cc0fcfc3c7c0fdc061e ? I am getting a different backtrace for this case. Actually this might be a different bug/limitation that should be submitted to libsass separately I think.

@saper
Copy link
Member

saper commented Jan 3, 2016

Full backtrace obtained from the singularity project seems to be consistent with @xzyfer results https://gist.github.com/4cae7f96bd4bacb61d3d

@saper
Copy link
Member

saper commented Jan 3, 2016

So it looks like we are generating a monster - say 132 characters substitutions times 1673 bytes is 220836 with overhead (string terminators, unicode) can easily be more than 512 kilobytes on stack. Maybe libsass can be told to save stack between calls.

@xzyfer
Copy link
Contributor

xzyfer commented Jan 5, 2016

Sorry for the delay @saper. I saw the patch land in libuv. Sounds like this will magically fix itself in future version of Node.

Is there anything else we can do?

@saper
Copy link
Member

saper commented Jan 5, 2016

Not in the node-sass. Singularity and Ruby Sass need to do better string handling (as @mgreter suggests), on the libsass side we should be careful with our stack usage (I have yet to measure this a bit). But node-sass is plain innocent, as always!

@jiv-e
Copy link

jiv-e commented Apr 15, 2016

I got the same kind of error accidentally by circular @import statements. Like this:

A.scss

@import B.scss

B.scss

@import A.scss

It would be great to get a better error message. It took me for ages to figure this out.

@saper
Copy link
Member

saper commented Apr 17, 2016

@jiv-e can you file a bug at https://GitHub.com/sass/libsass/issues about the need to detect recursive imports? There might be a bug about test already.

@xzyfer
Copy link
Contributor

xzyfer commented Apr 17, 2016

I believe this is fixed in the beta.

npm install node-sass@beta
On 18 Apr 2016 2:42 AM, "Marcin Cieślak" notifications@github.com wrote:

@jiv-e https://github.com/jiv-e can you file a bug at
https://GitHub.com/sass/libsass/issues about the need to detect recursive
imports? There might be a bug about test already.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#1289 (comment)

jiongle1 pushed a commit to scantist-ossops-m2/node-sass that referenced this issue Apr 7, 2024
Create quoted strings coming via API
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants