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

node-sass Cause the process to collapse #2171

Open
sbfkcel opened this issue Nov 29, 2017 · 20 comments
Open

node-sass Cause the process to collapse #2171

sbfkcel opened this issue Nov 29, 2017 · 20 comments

Comments

@sbfkcel
Copy link

sbfkcel commented Nov 29, 2017

node-sass causes the process to cras

Please copy the following code (including comments and spaces, etc.)
Here is an example:

const sass = require('node-sass');
let result;

try {
    result = sass.renderSync({
        data:'$spriteBg:map-url($_spriteHello);                          //一二三四五六七'
    });
} catch (error) {
    //Catch error, the process crashed
    console.log(error);
};

if(result && result.css){
    console.log(result.css);
};

Tested, there are multiple versions of the problem.

  • NPM version (npm -v):4.2.0
  • Node version (node -v):7.10.0
  • Node Process (node -p process.versions):
{ http_parser: '2.7.0',
  node: '7.10.0',
  v8: '5.5.372.43',
  uv: '1.11.0',
  zlib: '1.2.11',
  ares: '1.10.1-DEV',
  modules: '51',
  openssl: '1.0.2k',
  icu: '58.2',
  unicode: '9.0',
  cldr: '30.0.3',
  tz: '2016j' }
  • Node Platform (node -p process.platform):darwin
  • Node architecture (node -p process.arch):x64
@sbfkcel sbfkcel changed the title node-sass 5.7.0 Cause the process to collapse node-sass Cause the process to collapse Nov 29, 2017
@nschonni
Copy link
Contributor

Running on sassmeister with ruby sass I get Undefined variable: "$_spriteHello".
Does this occur when you remove the non-UTF8 comment at the end of the string?

@sbfkcel
Copy link
Author

sbfkcel commented Nov 30, 2017

@nschonni
$ _spriteHello is not defined catch should be able to capture the error is not it? Instead of the process crashing.

This problem is very strange, try to delete or add some spaces before the comment can properly capture the error.

Behind the Chinese comment delete some characters is also normal to capture the error.

@nschonni
Copy link
Contributor

When I pasted the example without the trailing comments, Sassmiester produced the same error for libsass as Ruby. My hunch is that the chinese characters in a string that is assumed to be UTF8 is the issue

@sbfkcel
Copy link
Author

sbfkcel commented Nov 30, 2017

There will be mistakes (this should be), but the process will not collapse.

@sbfkcel
Copy link
Author

sbfkcel commented Nov 30, 2017

-1

@xzyfer
Copy link
Contributor

xzyfer commented Nov 30, 2017 via email

@sbfkcel
Copy link
Author

sbfkcel commented Nov 30, 2017

@xzyfer As the first example, the code is simple. SASS did not normally throw an error. But collapsed.

@xzyfer
Copy link
Contributor

xzyfer commented Mar 10, 2018

My guess is this is LibSass crashing. I am unable to reproduce this. The best chance at fixing this to create a repo that produces the crash so that we can debug it.

@sbfkcel
Copy link
Author

sbfkcel commented Mar 10, 2018

test1.jsNormal throwing error

const sass = require('node-sass');

let sassString = `div {background-color:$color;}                            //一二三四五六`,
    result;

try {
    result = sass.renderSync({
        data:sassString
    });
} catch (error) {
    console.log(error);
};

test2.js Process crashes

const sass = require('node-sass');

let sassString = `div {background-color:$color;}                             //一二三四五六`,
    result;

try {
    result = sass.renderSync({
        data:sassString
    });
} catch (error) {
    console.log(error);
};

test1.js and test2.js are only one space apart

@saper
Copy link
Member

saper commented Mar 12, 2018

I can't reproduce this with node-sass 4.8.1 and mode v9.6.1

What is the output of

env | egrep '^(LANG|LC_)'

@saper
Copy link
Member

saper commented Mar 12, 2018

Can you provide your test1.js and test2.js encoded (for example please use openssl like this):

 openssl base64 -in test1.js
 openssl base64 -in test2.js

@sbfkcel
Copy link
Author

sbfkcel commented Mar 12, 2018

snipaste_2018-03-12_09-51-16

@sbfkcel
Copy link
Author

sbfkcel commented Mar 12, 2018

openssl base64 -in test1.js

Y29uc3Qgc2FzcyA9IHJlcXVpcmUoJ25vZGUtc2FzcycpOwoKbGV0IHNhc3NTdHJp
bmcgPSBgZGl2IHtiYWNrZ3JvdW5kLWNvbG9yOiRjb2xvcjt9ICAgICAgICAgICAg
ICAgICAgICAgICAgICAgIC8v5LiA5LqM5LiJ5Zub5LqU5YWtYCwKICAgIHJlc3Vs
dDsKCnRyeSB7CiAgICByZXN1bHQgPSBzYXNzLnJlbmRlclN5bmMoewogICAgICAg
IGRhdGE6c2Fzc1N0cmluZwogICAgfSk7Cn0gY2F0Y2ggKGVycm9yKSB7CiAgICBj
b25zb2xlLmxvZyhlcnJvcik7Cn07

openssl base64 -in test2.js

Y29uc3Qgc2FzcyA9IHJlcXVpcmUoJ25vZGUtc2FzcycpOwoKbGV0IHNhc3NTdHJp
bmcgPSBgZGl2IHtiYWNrZ3JvdW5kLWNvbG9yOiRjb2xvcjt9ICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAvL+S4gOS6jOS4ieWbm+S6lOWFrWAsCiAgICByZXN1
bHQ7Cgp0cnkgewogICAgcmVzdWx0ID0gc2Fzcy5yZW5kZXJTeW5jKHsKICAgICAg
ICBkYXRhOnNhc3NTdHJpbmcKICAgIH0pOwp9IGNhdGNoIChlcnJvcikgewogICAg
Y29uc29sZS5sb2coZXJyb3IpOwp9Ow==

@sbfkcel
Copy link
Author

sbfkcel commented Mar 12, 2018

code.zip

@saper
Copy link
Member

saper commented Mar 18, 2018

Thanks, still cannot reproduce it ... the effect is the same on my platfrom. Can you try running node under gdb (gdb node test2.js) and produce a stacktrace (bt command in the debugger)? Having debug symbols for node would certainly be useful, but not sure where to get them from for your platform.

@saper saper added the OS - OSX label Mar 18, 2018
@sbfkcel
Copy link
Author

sbfkcel commented Mar 19, 2018

GNU gdb (GDB) 8.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin16.7.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from node...
warning: Could not open OSO archive file "/Users/iojs/build/ws/out/Release/libcares.a"

warning: Could not open OSO archive file "/Users/iojs/build/ws/out/Release/libhttp_parser.a"

warning: Could not open OSO archive file "/Users/iojs/build/ws/out/Release/libicudata.a"

warning: Could not open OSO archive file "/Users/iojs/build/ws/out/Release/libicui18n.a"

warning: Could not open OSO archive file "/Users/iojs/build/ws/out/Release/libicustubdata.a"

warning: Could not open OSO archive file "/Users/iojs/build/ws/out/Release/libicuucx.a"

warning: Could not open OSO archive file "/Users/iojs/build/ws/out/Release/libnghttp2.a"

warning: Could not open OSO archive file "/Users/iojs/build/ws/out/Release/libopenssl.a"

warning: Could not open OSO archive file "/Users/iojs/build/ws/out/Release/libuv.a"

warning: Could not open OSO archive file "/Users/iojs/build/ws/out/Release/libv8_base.a"

warning: Could not open OSO archive file "/Users/iojs/build/ws/out/Release/libv8_libbase.a"

warning: Could not open OSO archive file "/Users/iojs/build/ws/out/Release/libv8_libplatform.a"

warning: Could not open OSO archive file "/Users/iojs/build/ws/out/Release/libv8_libsampler.a"

warning: Could not open OSO archive file "/Users/iojs/build/ws/out/Release/libv8_snapshot.a"

warning: Could not open OSO archive file "/Users/iojs/build/ws/out/Release/libzlib.a"

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/gen/node_javascript.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/async-wrap.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/backtrace_posix.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/cares_wrap.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/connect_wrap.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/connection_wrap.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/env.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/fs_event_wrap.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/handle_wrap.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/inspector_agent.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/inspector_io.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/inspector_js_api.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/inspector_socket.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/inspector_socket_server.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/js_stream.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/module_wrap.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/node.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/node_api.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/node_buffer.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/node_config.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/node_constants.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/node_contextify.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/node_crypto.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/node_crypto_bio.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/node_crypto_clienthello.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/node_debug_options.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/node_dtrace.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/node_file.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/node_http2.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/node_http_parser.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/node_i18n.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/node_main.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/node_os.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/node_perf.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/node_platform.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/node_serdes.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/node_stat_watcher.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/node_url.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/node_util.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/node_v8.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/node_watchdog.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/node_zlib.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/pipe_wrap.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/process_wrap.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/signal_wrap.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/spawn_sync.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/stream_base.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/stream_wrap.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/string_bytes.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/string_search.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/tcp_wrap.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/timer_wrap.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/tls_wrap.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/tracing/agent.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/tracing/node_trace_buffer.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/tracing/node_trace_writer.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/tracing/trace_event.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/tty_wrap.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/udp_wrap.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/util.o': can't open to read symbols: No such file or directory.

warning: `/Users/iojs/build/ws/out/Release/obj.target/node/src/uv.o': can't open to read symbols: No such file or directory.
(no debugging symbols found)...done.
"/Users/fan/Downloads/default/test2.js" is not a core dump: File format not recognized
(gdb)

@sbfkcel
Copy link
Author

sbfkcel commented Mar 19, 2018

Windows also has this problem.

Is it related to the system language environment?

@saper
Copy link
Member

saper commented Mar 19, 2018

There is something special in your language set up, that is why we cannot reproduce it at the moment. What are your language settings on both systems?

@sbfkcel
Copy link
Author

sbfkcel commented Mar 20, 2018

Region: China
Language: Simplified Chinese

@saper
Copy link
Member

saper commented Oct 18, 2019

@sbfkcel are you still having this? Can you give me the output of

  env | egrep '^(LANG|LC_)'

I also made a mistake in the gdb command, it should be

  gdb --args node test2.js

after this type run and when it crashes type bt

When there is no crash it looks like this:

> gdb --args node test2.js 
GNU gdb (GDB) 8.3.1 [GDB v8.3.1 for FreeBSD]
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-portbld-freebsd12.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from node...
(No debugging symbols found in node)
(gdb) run
Starting program: /usr/local/bin/node test2.js
[New LWP 100821 of process 49002]
[New LWP 100882 of process 49002]
[New LWP 101403 of process 49002]
[New LWP 101407 of process 49002]
[New LWP 101408 of process 49002]
[New LWP 101414 of process 49002]
Error: Undefined variable: "$color".
    at Object.module.exports.renderSync (/home/saper/node_modules/node-sass/lib/index.js:439:16)
    at Object.<anonymous> (/home/saper/sw/node-sass-issue-2171/test2.js:7:19)
    at Module._compile (internal/modules/cjs/loader.js:945:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:962:10)
    at Module.load (internal/modules/cjs/loader.js:798:32)
    at Function.Module._load (internal/modules/cjs/loader.js:711:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1014:10)
    at internal/main/run_main_module.js:17:11 {
  status: 1,
  file: 'stdin',
  line: 1,
  column: 23,
  message: 'Undefined variable: "$color".',
  formatted: 'Error: Undefined variable: "$color".\n' +
    '        on line 1 of stdin\n' +
    '>> div {background-color:$color;}                             //一二三\n' +
    '   ----------------------^\n'
}
[LWP 101407 of process 49002 exited]
[LWP 100882 of process 49002 exited]
[LWP 100821 of process 49002 exited]
[LWP 101403 of process 49002 exited]
[LWP 101408 of process 49002 exited]
[LWP 101414 of process 49002 exited]
[Inferior 1 (process 49002) exited normally]
(gdb) bt
No stack.
(gdb) 

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants