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

Recursion triggers Segmentation Fault on Alpine Linux #2402

Closed
chearius opened this issue May 29, 2017 · 2 comments
Closed

Recursion triggers Segmentation Fault on Alpine Linux #2402

chearius opened this issue May 29, 2017 · 2 comments

Comments

@chearius
Copy link

I have encountered a problem with libsass while trying to build a Ionic Framework Application on Alpine Linux (ionic-team/ionic-app-scripts#955). I could localize the problem in the recursive implementation of str-replace function (similar to #1823) or in general any other form of recursive function call that exceed certain recursion depth (~10 - 20 depending on the system and function).

input.scss

This scss code is just for demonstration of the problem:

@function test-recursion($val, $recursion: 0) {
  @debug "Called recursion #{$recursion}";

  @if $recursion < 2000 {
    @return test-recursion($val, $recursion + 1);
  }

  @return $val;
}

.test {
  attribute: test-recursion("test");
}

Actual results

Using node-sass with this source produces a Segmentation fault on Alpine Linux (Tested with node 6 and 7)

[14:24:11] Starting 'sass'...
/srv/test/test.scss:2 DEBUG: Called recursion 0
/srv/test/test.scss:2 DEBUG: Called recursion 1
/srv/test/test.scss:2 DEBUG: Called recursion 2
/srv/test/test.scss:2 DEBUG: Called recursion 3
/srv/test/test.scss:2 DEBUG: Called recursion 4
/srv/test/test.scss:2 DEBUG: Called recursion 5
/srv/test/test.scss:2 DEBUG: Called recursion 6
/srv/test/test.scss:2 DEBUG: Called recursion 7
/srv/test/test.scss:2 DEBUG: Called recursion 8
/srv/test/test.scss:2 DEBUG: Called recursion 9
/srv/test/test.scss:2 DEBUG: Called recursion 10
/srv/test/test.scss:2 DEBUG: Called recursion 11
/srv/test/test.scss:2 DEBUG: Called recursion 12
/srv/test/test.scss:2 DEBUG: Called recursion 13
/srv/test/test.scss:2 DEBUG: Called recursion 14
/srv/test/test.scss:2 DEBUG: Called recursion 15
/srv/test/test.scss:2 DEBUG: Called recursion 16
/srv/test/test.scss:2 DEBUG: Called recursion 17
/srv/test/test.scss:2 DEBUG: Called recursion 18
Segmentation fault (core dumped)

Expected result

Clean termination of sass processing with error message similar to other platforms / Linux distributions:

Message:
    test.scss
Error: Stack depth exceeded max of 1024

version info:

Alpine Linux: 3.5 and 3.6 with nodejs and nodejs-current packages (NodeJS 6 and NodeJS 7).

$ node-sass --version
node-sass       4.5.3   (Wrapper)       [JavaScript]
libsass         3.5.0.beta.2    (Sass Compiler) [C/C++]
@mgreter
Copy link
Contributor

mgreter commented May 29, 2017

I'm pretty sure this is due to too small stack size. This is a compile time or/and runtime option which is not under libsass control. So nothing we can do here. Please follow upstream tickets about alpine linux support.

@chearius
Copy link
Author

The problem is, that libsass fails with segmentation fault (SIGSEGV) without any further information about the source of the problem (recursion depth, stack overflow or whatever). From my point of view, it should print an error message and terminate without segmentation fault.

Rebuilding libsass and node-sass bindings with -O0 doesn't help, it still triggers SIGSEGV.

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

2 participants