Skip to content

use node-inspector debug stop , then crash #2110

Description

@yjhjstz

I use node-inspector to debug , then I try to stop debug in my testcase, that's is to call Agent::Stop().
when I didn't closed the node-inspector, then I meat the crash . Otherwise I closed the node-inspector , it won't happen.
Here is the stack:

$2 = <optimized out>
(gdb) bt
#0 syscall () at ../sysdeps/unix/sysv/linux/x86_64/syscall.S:38
#1 0x0000000000c8222a in uv__epoll_wait (epfd=<optimized out>, events=events@entry=0x7f4ac3bc3dc0, nevents=nevents@entry=1024, timeout=timeout@entry=-1)
at ../deps/uv/src/unix/linux-syscalls.c:313
#2 0x0000000000c803dd in uv__io_poll (loop=loop@entry=0x2771800, timeout=-1) at ../deps/uv/src/unix/linux-core.c:216
#3 0x0000000000c70d33 in uv_run (loop=0x2771800, mode=UV_RUN_DEFAULT) at ../deps/uv/src/unix/core.c:323
#4 0x0000000000c5196b in node::debugger::Agent::WorkerRun() ()
#5 0x0000000000c7c5f8 in uv__thread_start (arg=<optimized out>) at ../deps/uv/src/unix/thread.c:49
#6 0x00007f4ac479a6aa in start_thread (arg=0x7f4ac3bc7700) at pthread_create.c:333
#7 0x00007f4ac44cfeed in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109


#0 0x00007f4ac479b8ed in pthread_join (threadid=139959088216528, thread_return=thread_return@entry=0x0) at pthread_join.c:90
90 pthread_join.c: No such file or directory.
(gdb) bt
#0 0x00007f4ac479b8ed in pthread_join (threadid=139959088216528, thread_return=thread_return@entry=0x0) at pthread_join.c:90
#1 0x0000000000c7c69e in uv_thread_join (tid=<optimized out>) at ../deps/uv/src/unix/thread.c:80
#2 0x0000000000c50efc in node::debugger::Agent::Stop() [clone .part.12] ()
#3 0x0000000000bf3896 in node::DispatchDebugMessagesAsyncCallback(uv_async_s*) ()
#4 0x0000000000c701ad in uv__async_event (loop=0x1302c00 <default_loop_struct>, w=<optimized out>, nevents=<optimized out>) at ../deps/uv/src/unix/async.c:89
#5 0x0000000000c70283 in uv__async_io (loop=0x1302c00 <default_loop_struct>, w=0x1302dc8 <default_loop_struct+456>, events=<optimized out>)
at ../deps/uv/src/unix/async.c:160
#6 0x0000000000c801fa in uv__io_poll (loop=loop@entry=0x1302c00 <default_loop_struct>, timeout=280) at ../deps/uv/src/unix/linux-core.c:305
#7 0x0000000000c70d33 in uv_run (loop=0x1302c00 <default_loop_struct>, mode=UV_RUN_ONCE) at ../deps/uv/src/unix/core.c:323
#8 0x0000000000bf7911 in node::Start(int, char**) ()
#9 0x00007f4ac43e9a40 in __libc_start_main (main=0x60db70 <main>, argc=2, argv=0x7ffde187f1f8, init=<optimized out>, fini=<optimized out>, 
rtld_fini=<optimized out>, stack_end=0x7ffde187f1e8) at libc-start.c:289
#10 0x000000000060dda9 in _start ()
(gdb) 

Then I try to fix it as below.

@@ -34,8 +34,13 @@ exports.start = function start() {
     process.listeners('SIGWINCH').forEach(function(fn) {
       process.removeListener('SIGWINCH', fn);
     });
-
+    // not more connection
     agent.close();
+    // close all client
+    agent.clients.forEach(function(client) {
+      client.destroy();
+    });
+
   };

The truth is that uv_run is blocked, I think the best way to slove is to close all clients in agent but not depend on client.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    c++Issues and PRs that require attention from people who are familiar with C++.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions