-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
node js 5.2.0 segmentation fault after console.log #4261
Comments
Do you get the same backtrace if you run under say gdb instead of using |
Here is the the backtrace when running under gdb:
[fixed formatting - ofrobots] |
The gdb backtrace suggests something calls |
I faced very similar issue. NodeJS crashed then I passed object to console.log. The problem seemed to be require('vm').runInDebugContext('Debug') inside util.inspect inside util.format. So I tried debugging this script: var Debug = require('vm').runInDebugContext('Debug')
console.log('a') I noticed that every time I stepped over require('vm').runInDebugContext('Debug') or set or triggered a breakpoint after this line had executed NodeJS crashed. If I ran this script without debugger attached or didn't set any breakpoints everything ran as expected. |
Steps to reproduce (make sure to use node 5.2.0 and npm 3.x):
Open the file "api/controllers/ExampleController.js", add a line in jQuery function:
Run the app: The "--debug" flag is very important! Open a browser, and go to "http://localhost:1339/". App crashes with segmentation fault. |
Thanks, I've been able to reproduce the issue. As a stop-gap measure (which may also end up being the final fix), you can apply this patch: diff --git a/src/debug-agent.cc b/src/debug-agent.cc
index 3409fb2..53be4f9 100644
--- a/src/debug-agent.cc
+++ b/src/debug-agent.cc
@@ -320,7 +320,11 @@ void Agent::EnqueueMessage(AgentMessage* message) {
void Agent::MessageHandler(const v8::Debug::Message& message) {
Isolate* isolate = message.GetIsolate();
+
Environment* env = Environment::GetCurrent(isolate);
+ if (env == nullptr)
+ return;
+
Agent* a = env->debugger_agent();
CHECK_NE(a, nullptr);
CHECK_EQ(isolate, a->parent_env()->isolate()); |
Yes, the patch fixes the segmentation fault. Thanks @bnoordhuis ! |
I'm not using SailsJS but I have the same problem. I'm using ExpressJS and after each console.log() the server stops to working. I'm using node v5.2.0 |
Fix a segmentation fault when the debug message handler was called from a context without an associated `node::Environment`. Fixes: nodejs#4261 Fixes: nodejs#4322
Fix a segmentation fault when the debug message handler was called from a context without an associated `node::Environment`. Fixes: nodejs#4261 Fixes: nodejs#4322 PR-URL: nodejs#4328 Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Fix a segmentation fault when the debug message handler was called from a context without an associated `node::Environment`. Fixes: nodejs#4261 Fixes: nodejs#4322 PR-URL: nodejs#4328 Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Fix a segmentation fault when the debug message handler was called from a context without an associated `node::Environment`. Fixes: nodejs#4261 Fixes: nodejs#4322 PR-URL: nodejs#4328 Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Fix a segmentation fault when the debug message handler was called from a context without an associated `node::Environment`. Fixes: nodejs#4261 Fixes: nodejs#4322 PR-URL: nodejs#4328 Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Fix a segmentation fault when the debug message handler was called from a context without an associated `node::Environment`. Fixes: nodejs#4261 Fixes: nodejs#4322 PR-URL: nodejs#4328 Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell <jasnell@gmail.com>
The segementation fault is easy to trigger. I use sailsJS and here are the lines to cause the crash:
The "console.log" reliably causes the nodeJS crash later on. The same code works fine on 5.1.1.
Trace from segfault-handler.node(+0x1af4)[0x7f9a58a9aaf4]:
The text was updated successfully, but these errors were encountered: