-
Notifications
You must be signed in to change notification settings - Fork 62
segfault in node.js v0.6.15 #24
Comments
Here is the backtrace, as well: (gdb) backtrace |
I'll be damned - I may have a patch. I'll send a pull request in a bit... |
Is it possible that you've upgraded Node versions without recompiling the native addons like Contextify? I'm wondering if the fresh compilation is what's making your patch work. If that's not the case, could you post the script you're running that shows this crash? |
When I first hit this error on node v.0.4.11, I had just installed node.io, so Contextify was freshly compiled in the .v.0.4.11 ecosystem. After I upgraded to v0.6.15, the lack of compilation is certainly possible, I am not familiar enough with the node and npm make processes to know if they recompiled addons or not. Tthe new npm bundling process that packages requirements with the requiring packages has me unclear what contributes the compiled version of an addon. The script is large, I will try and pare it down to a testcase today for the relevant URLs and send you that. |
FWIW, I just undid my "patch", and recompiled and am re-running my script. So far it appears you are correct. How embarrassing. |
No worries. Native addons with Node are anything but intuitive. Anytime you switch between major Node versions, you have to recompile the native addons. npm has a handy |
All that said, I think I have recreated it. At least, after butressing my code's error handling, I am getting the segfautls again. I'll post a testcase if I figure it out. |
I have a question - after reading the jsdom source, I see they are sending a window using createWindow() to Contextify, and then getting the global for that object, and setting window.window to it. In this gist(https://gist.github.com/2551818) is a session where I execute those commands, and I see that what is returned by the getGlobal does not equal the Contextified object. Can you take a look at my gist, and tell me if my assumption (getGlobal === contextified object) is correct? The relation to this bug is that when Contextify is fed bad javascript, the resulting exceptions appear to be causing memory leaks in Contextify. Many of those exceptions are "navigator is not defined", and I have tracked it down to this code in jsdom. |
Are you sure that the installation of JSDOM you're using with node.io has Contextify installed? Contextify is an optional dependency, and if it's not found, JSDOM tries to replicate the functionality with the I tried a similar experiment and got the following: var jsdom = require('jsdom');
var doc = jsdom.jsdom('<html><head></head><body></body></html>');
var window = doc.parentWindow;
console.log(window.window === window);
console.log(window.window.navigator); With Contextify:
Without Contextify:
As soon as I finish school (2 weeks from Wednesday), I'm going to finish work on a patch to get the Contextify behavior into Node's |
Yup - I have been curing some of the issues related to the segfault in Contextify, so as I install different versions of jsdom under node.io, I have to copy my contextify.cc into place and rebuild. |
I installed node.io and ran your gist verbatim.
The second part makes sense - window.window is the proxy global from the v8 context, while window is the sandbox object. getGlobal() returns the proxy object so you can set up self-references that behave correctly when executing code in the Contextify context. In context things work as expected:
The behavior you're seeing with the navigator really looks like you don't have Contextify installed. If I remove Contextify from JSDOM's node_modules, I get the exact behavior in your gist:
|
cusswords - npm rebuild was not working, so I was using node-waf. however, node-waf does not do the right thing for a module previously built with node-gyp. So, it appears I was not using the contextify.node that I thought I had been. I removed it all, reinstalled, and installed node-gyp, and then the basic node.io test case I have appears to work with my changes so far. Thank you very much for your help, I apologize for any frustration I caused. Now I am back to tracking down what on my end is causing jsdom or contextify to try and access a non-existent memory location, after running several scrapes in a row. I still get this note from valgrind: ==3204== Invalid read of size 4 ==3204== at 0x81C093B: v8::Object::GetRealNamedProperty(v8::Handlev8::String) (in /usr/local/bin/node) |
I am pretty clear now this is a jsdom/node.io issue. Not sure if I have it worked around or not, but I think I should take it off your plate. the only thing I did with contextify is to leave the patch I made in place, based upon my reading at http://groups.google.com/group/nodejs/browse_thread/thread/19c5ac046526a67a. Hope your schoolwork went well! |
There are details here: http://pastebin.com/McidkC0g and http://groups.google.com/group/nodejs/browse_thread/thread/d9eb8b66ce5cfc88
Here is the start of a gdb session with the error:
Not sure can contribute a patch, but I am looking at it now. Thanks in advance.
The text was updated successfully, but these errors were encountered: