-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Defining importer function gives Abort trap: 6 error #586
Comments
Thanks for reporting this bug. I am able to reproduce it. It's actually one of the known issue of this release which is causing the CI build failed as well. With @browniefed's example and first time using gdb :), I am actually able to narrow it down. It is due to libuv Diagnostic steps:- `nano /tmp/foo.scss` and paste the following@import "non-existing-file.scss";
.test {
color: #000;
}
require("./").render({
file: '/tmp/foo.scss',
outputStyle: 'compressed',
success: function (result) {
// the result string
console.log(result.css);
},
error: function(err) {
console.log(err);
},
importer: function(url) {console.log(url);
return {file: url};
}
}); It will return
{ status: 1,
file: '/tmp/foo.scss',
line: 1,
column: 9,
message: 'file to import not found or unreadable: testimport\non-existing-file dir: /tmp/',
code: 1 }
I could not find a way to built this feature with pure "Native abstractions for node.js (nan)" (which is supposed to take care of cross v8 versions), after going through their docs: https://github.com/rvagg/nan/blob/master/README.md. We need to call the |
Forgot to mention, you would need to |
@mgreter, do we need to free |
No, either you Just saw that you were asking about values on your code side. No idea if you need to free them, but if you made a copy or have taken the memory from ctx, you actually do (need to free that on your own)! |
Maybe I'm doing something wrong but I'm still getting the Abort trap error. I cloned your master node-sass repo on your account @am11 , followed the node-gyp rebuild process. Moved the binding.node into the vendor folder. Ran an |
I'm afk atm. The steps you described have one catch, run npm install and then node-gyp rebuild (won't work if you do the other way around). -- best Sent from my Windows Phone From: Jason Brownmailto:[email protected] Maybe I'm doing something wrong but I'm still getting the Abort trap error. I cloned your master node-sass repo on your account @am11 , followed the node-gyp rebuild process. Moved the binding.node into the vendor folder. Ran an Reply to this email directly or view it on GitHub: |
The Regardless I still get the Abort Trap error, I compiled the debug version expecting more output than the abort trap error but still only just that got logged in console. |
More info, it appears that renderSync works but then only synchronous importers are allowed, but just a simple render throws the Abort Trap error |
The only change I made before pushing is to revert back libsass to old commit, because we only update submodule in the repo, when libsass gets a tag release (v3.1.0-beta for instance). cd src/libsass
git remote add libsass https://github.com/sass/libsass
git pull --rebase libsass master
cd ../..
node-gyp rebuild -d Regarding |
@am11 I tried updating the submodule and still get the Abort trap error. This works. var sass = require('node-sass');
var css = "@import \"non-existing-file\"; \n.test {\ncolor: #000;\n}";
var x = sass.renderSync({
data: css,
outputStyle: 'compressed',
importer: function(url) {
return {contents: 'div { color: #000; }'};
}
});
console.log(x); This does not var sass = require('node-sass');
var css = "@import \"non-existing-file\"; \n.test {\ncolor: #000;\n}";
sass.render({
data: css,
outputStyle: 'compressed',
success: function(result) {
console.log(result);
},
importer: function(url, prev, done) {
done({contents: 'div { color: #000; }'});
}
}); I tried following your debug instructions, I got gdb, but wasn't sure about setting up the project in eclipse so I could debug it, and also wasn't sure how to attach the process to node repl. |
Tip: if your pwd is node-sass cloned repo's root directory, change this: var sass = require('node-sass'); to: var sass = require('./'); Here is what I am getting in Ubuntu 12 with this code: require("./").render({
data: "@import \"non-existing-file\"; \n.test {\ncolor: #000;\n}",
outputStyle: 'compressed',
success: function(result) {
console.log(result);
},
error: function(error) {
console.log(error);
},
importer: function(url, prev, done) {
done({contents: 'div { color: #000; }'});
}
}); Bash: vagrant@precise64:/temp/node-sass$ pwd
/temp/node-sass
vagrant@precise64:/temp/node-sass$ node
> require("./").render({
... data: "@import \"non-existing-file\"; \n.test {\ncolor: #000;\n}",
... outputStyle: 'compressed',
... success: function(result) {
..... console.log(result);
..... },
... error: function(error) {
..... console.log(error);
..... },
... importer: function(url, prev, done) {
..... done({contents: 'div { color: #000; }'});
..... }
... });
undefined
> { css: 'div{color:#000}.test{color:#000}',
map: '{}',
stats:
{ entry: 'data',
start: 1419805648786,
includedFiles: [ 'non-existing-file' ],
end: 1419805648787,
duration: 1 } } |
Sorry my setup may be a little confusing, I just deleted all traces of npm install node-sass and did a git clone into node_modules. Still getting the Abort trap: 6 error. Must be a mac thing?
|
Do you get the same result when compile without -d? cd ~/node-sass/
rm -rf build
node-gyp rebuild
node I was getting assertion failed followed by node process termination in Windows, after it prints the libsass error: C:\users\Adeel\Source\Repos\node-sass [master +0 ~1 -0]> node
> require("./").render({
... data: "@import \"non-existing-file\"; \n.test {\ncolor: #000;\n}",
... outputStyle: 'compressed',
... success: function(result) {
..... console.log(result);
..... },
... error: function(error) {
..... console.log(error);
..... },
... importer: function(url, prev, done) {
..... done({contents: 'div { color: #000; }'});
..... }
... });
undefined
> { css: 'div{color:#000}.test{color:#000}',
map: '{}',
stats:
{ entry: 'data',
start: 1419808592203,
includedFiles: [ 'non-existing-file' ],
end: 1419808598300,
duration: 6097 } }
Assertion failed: 0, file d:\jenkins\workspace\nodejs-msi\22874dd8\deps\uv\src\win\handle-inl.h, line 158
C:\users\Adeel\Source\Repos\node-sass [master +0 ~1 -0]> I recompiled without |
@am11 tested both with -d and without and still get the error on mac. I did a rebuild on a windows environment and everything works fine there, I haven't tested a vagrant ubuntu environment yet but I imagine it'll work well there. Seems that Mac is the culprit, |
@browniefed, it's not really the OS thing. The difference in behavior is probably due to the way OSes initiate and manage processes. For instance, npm test is passing on Windows, but after running a very specific stats test, it fails on Linux (https://travis-ci.org/sass/node-sass/jobs/45288685#L599). Our code has more bugs which need fixing. Currently, I am working on another weird behavior on Linux. Its basically a "manual stress" testing to make this feature bullet proof. For instance, copy these two chunks: require("./").render({
file: "test/fixtures/include-files/index.scss",
outputStyle: 'compressed',
success: function(result) {
console.log(result);
},
error: function(error) {
console.log(error);
},
importer: function(url, prev, done) {
done({contents: 'div { color: #000; }'});
}
});
require("./").render({
file: "test/fixtures/include-files/index.scss",
outputStyle: 'compressed',
success: function(result) {
console.log(result);
},
error: function(error) {
console.log(error);
}
}); And paste it like 40-50 times in editor. The copy the whole blob and paste in node.js console. Ubuntu blows with So we have like five moving parts here, OS, libuv, v8, nan and libsass. And the sixth one is our binding code gluing them together! All we need is to make sure that all of them are on board, which is bit painful, when you get some gibberish thrown by debugger from memory heaps. After reading this: http://stackoverflow.com/a/5856959/863980, I think I am going to try valgrind soon! Hopefully we will get somewhere. The catch is: if we do |
to expand on this: cd into/cloned/dir/of/node-sass
gdb node
run ./node_modules/.bin/mocha test
# where test is a directory containing test GDB will throw the following on test failure:
this happens after running the test |
Ah wow I was unaware the current environment was such a mish-mash of libraries. I wish I could be of more assitance, I'm not exactly skilled in the ways of C++ development but I really appreciate all this work you're putting in to get this figured out. The whole processing of importers concept is great and powerful and should make extending sass without ruby a breeze. |
On Ubuntu, https://wiki.ubuntu.com/Valgrind made it super easy to configure valgrind and detect memory leaks: sudo apt-get install valgrind
# mkdir /temp
# git clone node-sass https://github.com/am11/node-sass --recursive
# cd /temp/node-sass
# git submodule --recursive --init
# npm install
# node-gyp rebuild -d
G_SLICE=always-malloc G_DEBUG=gc-friendly valgrind -v --tool=memcheck --leak-check=full --show-reachable=yes --num-callers=40 --log-file=valgrind.log $(which node) node_modules/.bin/mocha test Will produce valgrind.log in current dir. |
@am11: First let me be clear: I really think the problem is not in libsass but with (the usage of) libuv. Next: I don't know shit about libuv but tried to hunt down your nasty race condition anyway. So here my uneducated guesses: The error can also be avoided if this line in I guess that's as much as I want to dive into the whole libuv stuff. But I'm pretty convinced that the cluprit is somewhere in there. But I also could be totally wrong here! As a side note: You should be aware that |
@mgreter, thanks for looking into it. You are right about Now with the tip of my master branch, I generated two different sets of logs on Ubuntu: Valgrind: https://gist.github.com/am11/6cfcebdef05e3751f16d#file-valgrind-log-L151 Both captured the SIGSEGV thrown after running a specific stat-related test and free()'ing the memory. At libuv IRC channel, someone suggested me to change calloc call with C++ style memory allocation ( There is another odd behavior i'm facing when dealing with CLI. I think they might be related (implicitly?). Besides having uv_async_send, uv_cond_wait, uv_mutex, it seems like libuv require some kind of a "push" or another signal to run. According to the docs, uv_async_send runs at least once! But in this case either the thread is sleeping or there is some kind of a deadlock. |
You should only free the memory from the uv_close callback. void uv_close(uv_handle_t* handle, uv_close_cb close_cb) Can for example be done with |
@kkoopa, thanks for your advice. I have applied this patch locally: https://gist.github.com/am11/6b227670e5a827ed2c15. |
Hello @browniefed, the TravisCI build is now passing and we will release v2.0.0 🔜'ish. I can confirm that the build is pretty ok on both Linux and Windows. Could you please give it another try (with my master branch) on OSX and confirm if the issue is fixed there? :) |
No go. Still getting the abort trap error. 😢
paste require("./").render({
data: "@import \"non-existing-file\"; \n.test {\ncolor: #000;\n}",
outputStyle: 'compressed',
success: function(result) {
console.log(result);
},
error: function(error) {
console.log(error);
},
importer: function(url, prev, done) {
done({contents: 'div { color: #000; }'});
}
});
In attempting to be useful I'm running Mac OSX 10.9 Mavericks so luckily valgrind works on it. I got it installed and ran it with the commands you had up above. I get to the importer tests and everything then it just sits there doing nothing. https://gist.github.com/browniefed/cad5225b63f02b747e24 |
@browniefed, thanks for the details. Please show the output of On Linux and Windows, it is giving me this result: require("./").render({
... data: "@import \"non-existing-file\"; \n.test {\ncolor: #000;\n}",
... outputStyle: 'compressed',
... success: function(result) {
..... console.log(result);
..... },
... error: function(error) {
..... console.log(error);
..... },
... importer: function(url, prev, done) {
..... done({contents: 'div { color: #000; }'});
..... }
... });
undefined
> { css: 'div{color:#000}.test{color:#000}',
map: '{}',
stats:
{ entry: 'data',
start: 1420517121859,
includedFiles: [ 'non-existing-file' ],
end: 1420517121861,
duration: 2 } } |
|
If there is nothing useful in those valgrind logs I'll run any other valgrind stuff (i.e. not running it against mocha tests, etc). Just let me know |
I'm very sorry that I don't have the bandwidth to digest or continue with this issue but I do want to point to my earlier comments @ #576 (comment) which I still stand by and suspect might be related to the problems here. I'm unsubscribing from this thread but feel free to rope me back in by @-mention if you have something concrete for me to discuss. You should also lean on @koopa's expertise here if you can. |
Discussion at sass#586.
Our requirement is bit different and unfortunately that cannot be accomplished by the pure-nan solution. Here is the proof-of-concept how it would look like in pure-nan terms: b2da1c7. But it throws exception at Perhaps it is possible with something other than |
@browniefed, I do not have Mac and unfortunately I cannot test darwin binary at this point. So v2.0.0 would probably not be stable for Mac. We will keep this issue open, so in future, anyone with OSX can debug and spot what is wrong there. Nonetheless, we are at a much better place where we were 10 days ago. So thanks again for reporting this issue! :) |
This is fixed by 0720fa8 and ff53926 via #615. Once again, thanks for everyone who helped us pulling this one off. 👍 🎉 |
I just updated to the latest node-sass master, but I still get |
@callumlocke could you say anything about the process? Did you build custom, or did you let it install the binaries off of node-sass-binaries? |
I just did git pull to get the latest code, then npm install. I didn't do It works fine until I define an importer function.
|
@callumlocke please follow this
|
awesome, thanks |
By simply defining an importer function an Abort trap: 6 gets thrown whenever I attempt to run anything with an import.
The text was updated successfully, but these errors were encountered: