Skip to content
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

can not step in constructor, will will terminate node.exe #4307

Closed
flyingcodes opened this issue Dec 16, 2015 · 11 comments
Closed

can not step in constructor, will will terminate node.exe #4307

flyingcodes opened this issue Dec 16, 2015 · 11 comments
Labels
v8 engine Issues and PRs related to the V8 dependency.

Comments

@flyingcodes
Copy link

i report the bug to Microsoft/vscode in microsoft/vscode#953. then, They reply the bug is caused by node.js.

1
2
3

class CA {
    constructor(){      
    }   
}

class CB extends CA {
    constructor(p){
        super(p);
    }
}


var cb = null; // debugger pointer
//cb = new CB(123); // can not step in, will terminate node.exe
cb = new CB(); // step in, then follow line can step in, else can not
cb = new CB(123); // can step in if above is step in
console.log(cb); 

[fixed fomatting - bnoordhuis]

@fl0w
Copy link

fl0w commented Dec 16, 2015

I tried running the code in in 4.2.3, 5.0.0, 5.1.1 and 5.2.0 on Mac OS X (Yosemite).

/* 4307.js */
class CA { constructor(p) { console.log(p) } }
class CB extends CA {
  constructor(p) {
    super(p)
  }
}
var cb = null
cb = new CB(123)

Running $ node 4307.js fails on all versions expectedly without strict mode enabled, and works on all versions as expected with strict mode.

I experienced no issues in REPL on either version.

Leaving this here for reference only

@mscdex mscdex added the v8 engine Issues and PRs related to the V8 dependency. label Dec 16, 2015
@flyingcodes
Copy link
Author

@fl0w did you debug it? can you step in cb = new CB(123)?

@targos
Copy link
Member

targos commented Dec 16, 2015

I can confirm the problem:

test % more debug.js 
class CA { constructor(p) { console.log(p) } }
class CB extends CA {
  constructor(p) {
    super(p)
  }
}
var cb = null
cb = new CB(123)

test % node -v
v5.2.0
test % node debug --use-strict debug.js 
< Debugger listening on port 5858
connecting to 127.0.0.1:5858 ... ok
break in debug.js:7
  5   }
  6 }
> 7 var cb = null
  8 cb = new CB(123)
  9 
debug> n
break in debug.js:8
  6 }
  7 var cb = null
> 8 cb = new CB(123)
  9 
 10 
debug> s
program terminated

@bnoordhuis
Copy link
Member

Can confirm the issue and it doesn't look like it's #4261. The stack trace seems to suggest a V8 bug.

(gdb) bt 16
#0  0x0000000000a5e0d1 in v8::internal::RootMarkingVisitor::VisitPointers(v8::internal::Object**, v8::internal::Object**) ()
#1  0x0000000000a158f6 in v8::internal::InternalFrame::Iterate(v8::internal::ObjectVisitor*) const ()
#2  0x0000000000b2d659 in v8::internal::Isolate::Iterate(v8::internal::ObjectVisitor*, v8::internal::ThreadLocalTop*) ()
#3  0x0000000000a3a016 in v8::internal::Heap::IterateStrongRoots(v8::internal::ObjectVisitor*, v8::internal::VisitMode) ()
#4  0x0000000000a6e7cc in v8::internal::MarkCompactCollector::MarkLiveObjects() ()
#5  0x0000000000a6ecb5 in v8::internal::MarkCompactCollector::CollectGarbage() ()
#6  0x0000000000a30211 in v8::internal::Heap::MarkCompact() ()
#7  0x0000000000a3c400 in v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) ()
#8  0x0000000000a3cbd0 in v8::internal::Heap::CollectGarbage(v8::internal::GarbageCollector, char const*, char const*, v8::GCCallbackFlags) [clone .constprop.454] ()
#9  0x0000000000a3e26f in v8::internal::Heap::CollectAllGarbage(int, char const*, v8::GCCallbackFlags) ()
#10 0x00000000009c49db in v8::internal::Debug::PrepareFunctionForBreakPoints(v8::internal::Handle<v8::internal::SharedFunctionInfo>) ()
#11 0x00000000009c582c in v8::internal::Debug::EnsureDebugInfo(v8::internal::Handle<v8::internal::SharedFunctionInfo>, v8::internal::Handle<v8::internal::JSFunction>) ()
#12 0x00000000009c5fb4 in v8::internal::Debug::FloodWithOneShot(v8::internal::Handle<v8::internal::JSFunction>, v8::internal::BreakLocatorType) ()
#13 0x00000000009c6799 in v8::internal::Debug::HandleStepIn(v8::internal::Handle<v8::internal::Object>, bool) ()
#14 0x0000000000c26a20 in v8::internal::Runtime_HandleStepInForDerivedConstructors(int, v8::internal::Object**, v8::internal::Isolate*) ()
#15 0x00002912ed20803b in ?? ()

@fl0w
Copy link

fl0w commented Dec 16, 2015

@flyingcodes sorry, I misread original report.

Already confirmed but I'll just complete my original response.
Using v5.0.0+ I cannot step through the application on Mac OS X Yosemite.
On v4.2.3, it works for me.

v5.0.0, v5.1.1, v5.2.0

$ node -v
v5.2.0
$ node debug --use-strict 4307.js 
< Debugger listening on port 5858
connecting to 127.0.0.1:5858 ... ok
break in 4307.js:10
  8 }
  9 
>10 var cb = null
 11 cb = new CB(123)
 12 
debug> n
break in 4307.js:11
  9 
 10 var cb = null
>11 cb = new CB(123)
 12 
 13 });
debug> s
program terminated

v4.2.3

$ node -v
v4.2.3
$ node debug --use-strict 4307.js 
< Debugger listening on port 5858
debug> . ok
break in 4307.js:1
> 1 'use strict'
  2 
  3 class CA { constructor(p) { console.log(p) } }
debug> n
break in 4307.js:10
  8 }
  9 
>10 var cb = null
 11 cb = new CB(123)
 12 
debug> n
break in 4307.js:11
  9 
 10 var cb = null
>11 cb = new CB(123)
 12 
 13 });
debug> s
break in 4307.js:5
  3 class CA { constructor(p) { console.log(p) } }
  4 class CB extends CA {
> 5   constructor(p) {
  6     super(p)
  7   }
debug> bt
#0 4307.js:5:14
#1 4307.js:11:6
debug> 

@bnoordhuis
Copy link
Member

After some more investigation it doesn't look like it's #4297 either; or at least, #4298 doesn't fix it. Here is a backtrace from a debug build.

Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00000000010bb173 in v8::internal::MarkBit::Get (this=0x7fff83e1b840) at ../deps/v8/src/heap/spaces.h:129
129       inline bool Get() { return (*cell_ & mask_) != 0; }
[Current thread is 1 (Thread 0x7f02ab8b8740 (LWP 14366))]

(gdb) p *this
$1 = {cell_ = 0xc0, mask_ = 1}  # cell_ is not a valid pointer

(gdb) bt 25
#0  0x00000000010bb173 in v8::internal::MarkBit::Get (this=0x7fff83e1b840) at ../deps/v8/src/heap/spaces.h:129
#1  0x000000000116306a in v8::internal::Marking::IsBlackOrGrey (mark_bit=...) at ../deps/v8/src/heap/mark-compact.h:69
#2  0x0000000001172d74 in v8::internal::RootMarkingVisitor::MarkObjectByPointer (this=0x7fff83e1bcd0, p=0x7fff83e1c718) at ../deps/v8/src/heap/mark-compact.cc:1531
#3  0x0000000001172cf5 in v8::internal::RootMarkingVisitor::VisitPointers (this=0x7fff83e1bcd0, start=0x7fff83e1c708, end=0x7fff83e1c760)
    at ../deps/v8/src/heap/mark-compact.cc:1517
#4  0x00000000011172f0 in v8::internal::StandardFrame::IterateExpressions (this=0x7fff83e1bb48, v=0x7fff83e1bcd0) at ../deps/v8/src/frames.cc:1356
#5  0x000000000111738a in v8::internal::InternalFrame::Iterate (this=0x7fff83e1bb48, v=0x7fff83e1bcd0) at ../deps/v8/src/frames.cc:1369
#6  0x0000000001282a35 in v8::internal::Isolate::Iterate (this=0x3b7cd00, v=0x7fff83e1bcd0, thread=0x3b7e528) at ../deps/v8/src/isolate.cc:203
#7  0x0000000001282a97 in v8::internal::Isolate::Iterate (this=0x3b7cd00, v=0x7fff83e1bcd0) at ../deps/v8/src/isolate.cc:210
#8  0x00000000011577ac in v8::internal::Heap::IterateStrongRoots (this=0x3b7cd20, v=0x7fff83e1bcd0, mode=v8::internal::VISIT_ONLY_STRONG) at ../deps/v8/src/heap/heap.cc:4504
#9  0x0000000001173979 in v8::internal::MarkCompactCollector::MarkRoots (this=0x3baff20, visitor=0x7fff83e1bcd0) at ../deps/v8/src/heap/mark-compact.cc:1810
#10 0x0000000001174b49 in v8::internal::MarkCompactCollector::MarkLiveObjects (this=0x3baff20) at ../deps/v8/src/heap/mark-compact.cc:2137
#11 0x000000000116eee6 in v8::internal::MarkCompactCollector::CollectGarbage (this=0x3baff20) at ../deps/v8/src/heap/mark-compact.cc:341
#12 0x0000000001148869 in v8::internal::Heap::MarkCompact (this=0x3b7cd20) at ../deps/v8/src/heap/heap.cc:1387
#13 0x00000000011480fa in v8::internal::Heap::PerformGarbageCollection (this=0x3b7cd20, collector=v8::internal::MARK_COMPACTOR, gc_callback_flags=v8::kNoGCCallbackFlags)
    at ../deps/v8/src/heap/heap.cc:1261
#14 0x0000000001147189 in v8::internal::Heap::CollectGarbage (this=0x3b7cd20, collector=v8::internal::MARK_COMPACTOR, gc_reason=0x17adf6a "prepare for break points", 
    collector_reason=0x17d9814 "GC in old space requested", gc_callback_flags=v8::kNoGCCallbackFlags) at ../deps/v8/src/heap/heap.cc:972
#15 0x0000000000dc80bf in v8::internal::Heap::CollectGarbage (this=0x3b7cd20, space=v8::internal::OLD_SPACE, gc_reason=0x17adf6a "prepare for break points", 
    callbackFlags=v8::kNoGCCallbackFlags) at ../deps/v8/src/heap/heap-inl.h:528
#16 0x0000000001146b81 in v8::internal::Heap::CollectAllGarbage (this=0x3b7cd20, flags=2, gc_reason=0x17adf6a "prepare for break points", 
    gc_callback_flags=v8::kNoGCCallbackFlags) at ../deps/v8/src/heap/heap.cc:828
#17 0x0000000001090742 in v8::internal::Debug::PrepareFunctionForBreakPoints (this=0x3b87460, shared=...) at ../deps/v8/src/debug/debug.cc:1314
#18 0x0000000001091383 in v8::internal::Debug::EnsureDebugInfo (this=0x3b87460, shared=..., function=...) at ../deps/v8/src/debug/debug.cc:1501
#19 0x000000000108e5af in v8::internal::Debug::FloodWithOneShot (this=0x3b87460, function=..., type=v8::internal::ALL_BREAK_LOCATIONS) at ../deps/v8/src/debug/debug.cc:735
#20 0x000000000108ea36 in v8::internal::Debug::FloodWithOneShotGeneric (this=0x3b87460, function=..., holder=...) at ../deps/v8/src/debug/debug.cc:795
#21 0x000000000108fa3d in v8::internal::Debug::HandleStepIn (this=0x3b87460, function_obj=..., is_constructor=true) at ../deps/v8/src/debug/debug.cc:1108
#22 0x00000000013e9b5a in v8::internal::__RT_impl_Runtime_HandleStepInForDerivedConstructors (args=..., isolate=0x3b7cd00) at ../deps/v8/src/runtime/runtime-classes.cc:492
#23 0x00000000013e9a50 in v8::internal::Runtime_HandleStepInForDerivedConstructors (args_length=1, args_object=0x7fff83e1c708, isolate=0x3b7cd00)
    at ../deps/v8/src/runtime/runtime-classes.cc:486
#24 0x000009aee5a060bb in ?? ()

@flyingcodes
Copy link
Author

@fl0w @targos @bnoordhuis
node.exe is terminated while i debug it with harmony option in command line, v5.0.0 on windows 7 x64:

C:\Users\JS06\Desktop\vsc>node debug --harmony t1.js
< Debugger listening on port 5858
debug> . ok
break in C:\Users\JS06\Desktop\vsc\t1.js:2
  1
> 2 class CA {
  3     constructor(){
  4     }
debug> n
break in C:\Users\JS06\Desktop\vsc\t1.js:14
 12
 13
>14 var cb = null; // debugger pointer
 15 //cb = new CB(123); // can not step in, will terminate node.exe
 16 cb = new CB(); // step in, then follow line can step in, else can not
debug> n
break in C:\Users\JS06\Desktop\vsc\t1.js:16
 14 var cb = null; // debugger pointer
 15 //cb = new CB(123); // can not step in, will terminate node.exe
>16 cb = new CB(); // step in, then follow line can step in, else can not
 17 cb = new CB(123); // can step in if above is step in
 18 console.log(cb);
debug> n
break in C:\Users\JS06\Desktop\vsc\t1.js:17
 15 //cb = new CB(123); // can not step in, will terminate node.exe
 16 cb = new CB(); // step in, then follow line can step in, else can not
>17 cb = new CB(123); // can step in if above is step in
 18 console.log(cb);
 19 });
debug> s
program terminated
program terminated
program terminated
program terminated
program terminated
program terminated
program terminated
program terminated
program terminated
debug> . failed, please retry

C:\Users\JS06\Desktop\vsc>

terminated when step in at line 17

@jasnell
Copy link
Member

jasnell commented Apr 2, 2016

This appears to be fixed in master. Perhaps there's a fix that can be backported? @ofrobots

@ofrobots
Copy link
Contributor

ofrobots commented Apr 4, 2016

This seems to have been fixed in the V8 4.9 branch. The 20160302 nightly fails but the 20160307 nightly passes. I will see if I can identify the commit that fixed it.

@ofrobots
Copy link
Contributor

ofrobots commented Apr 4, 2016

This was fixed by v8/v8@14ec485. We will also need follow-on fix v8/v8@fc4c551 for PowerPC support, and v8/v8@30d6a4d for x87.

I am -0 on backporting this to v5.x. It might be worth waiting for v6.0 due out in a couple of weeks.

@targos
Copy link
Member

targos commented Jul 11, 2016

Closing as this is fixed in v6.x.

@targos targos closed this as completed Jul 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v8 engine Issues and PRs related to the V8 dependency.
Projects
None yet
Development

No branches or pull requests

7 participants