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

VM crashes with breakpoint on break statement #36622

Closed
DanTup opened this issue Apr 13, 2019 · 3 comments
Closed

VM crashes with breakpoint on break statement #36622

DanTup opened this issue Apr 13, 2019 · 3 comments
Assignees
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.

Comments

@DanTup
Copy link
Collaborator

DanTup commented Apr 13, 2019

This was raised at Dart-Code/Dart-Code#1617. I can reproduce using today's nightly build with just this Dart script (run directly - no Flutter):

Future<void> main() async {
  for (int i = 0; i < 2; i++) {
    if (i > 0) {
      break; // breakpoint here
    }
    await Future.delayed(Duration(seconds: 1));
  }
}

Some observations from @kinex:

Few observations:

  • both the break and the await statements are required for the crash to occur
  • there is no crash if the breakpoint is removed
  • it won't crash if you replace the break statement with a continue statement

Here's the crash:

-------------------------
Encountered context mismatch
	ctx_slot: 0
	frame_ctx_level: 1
	var_ctx_level: 0

-------------------------
Current frame:
[ Frame pc(0x1089ed401) fp(0x700004a56d80) sp(0x700004a56d08)
	function = :async_op
	url = file:///Users/danny/Dev/Game/tool/test.dart
	line = 4
	context = Context num_variables: 9
	context level = 1 ]

-------------------------
Context contents:
        Context@0x1067a1089 vars(9) {
          [0] = Instance of '_AsyncAwaitCompleter<void>'
          [1] = null
          [2] = [first 50 chars:] <asynchronous suspension>
#0      _startIsolate.<a...
          [3] = Closure: ([dynamic, dynamic, dynamic]) => dynamic
          [4] = Closure: (dynamic, dynamic) => dynamic
          [5] = 1
          [6] = [first 50 chars:] Context num_variables: 1 parent:{ Context num_vari...
          [7] = Context num_variables: 9
          [8] = Closure: ([dynamic, dynamic, dynamic]) => dynamic
        }
-------------------------
Debugger stack trace...

#0000 [ Frame pc(0x1089ed401) fp(0x700004a56d80) sp(0x700004a56d08)
	function = :async_op
	url = file:///Users/danny/Dev/Game/tool/test.dart
	line = 4
	context = Context: null
	context level = 1 ]
#0001 [ Frame pc(0x1089fb458) fp(0x700004a56de0) sp(0x700004a56d90)
	function = _RootZone@8048458.runUnary
	url = dart:async/zone.dart
	line = 1379
	context = Context: null
	context level = -1 ]
#0002 [ Frame pc(0x1089fb005) fp(0x700004a56e30) sp(0x700004a56df0)
	function = _FutureListener@8048458.handleValue
	url = dart:async/future_impl.dart
	line = 126
	context = Context: null
	context level = -1 ]
#0003 [ Frame pc(0x1089fac08) fp(0x700004a56ea8) sp(0x700004a56e40)
	function = _Future@8048458.handleValueCallback
	url = dart:async/future_impl.dart
	line = 639
	context = Context: null
	context level = 0 ]
#0004 [ Frame pc(0x1089f9c32) fp(0x700004a56f28) sp(0x700004a56eb8)
	function = _Future@8048458._propagateToListeners@8048458
	url = dart:async/future_impl.dart
	line = 668
	context = Context: null
	context level = 2 ]
#0005 [ Frame pc(0x1089f853a) fp(0x700004a56f70) sp(0x700004a56f38)
	function = _Future@8048458._complete@8048458
	url = dart:async/future_impl.dart
	line = 473
	context = Context: null
	context level = -1 ]
#0006 [ Frame pc(0x1089f7f1a) fp(0x700004a56fe8) sp(0x700004a56f80)
	function = Future.<anonymous closure>
	url = dart:async/future.dart
	line = 313
	context = Context: null
	context level = 0 ]
#0007 [ Frame pc(0x1089f7d34) fp(0x700004a57038) sp(0x700004a56ff8)
	function = Timer.<anonymous closure>
	url = dart:async-patch/timer_patch.dart
	line = 21
	context = Context: null
	context level = 0 ]
#0008 [ Frame pc(0x1089f6da5) fp(0x700004a57110) sp(0x700004a57088)
	function = _Timer@1026248._runTimers@1026248
	url = dart:isolate-patch/timer_impl.dart
	line = 382
	context = Context: null
	context level = -1 ]
#0009 [ Frame pc(0x1089f56c3) fp(0x700004a57148) sp(0x700004a57120)
	function = _Timer@1026248._handleMessage@1026248
	url = dart:isolate-patch/timer_impl.dart
	line = 416
	context = Context: null
	context level = -1 ]
#0010 [ Frame pc(0x1089ea073) fp(0x700004a57208) sp(0x700004a571e0)
	function = _RawReceivePortImpl@1026248._handleMessage@1026248
	url = dart:isolate-patch/isolate_patch.dart
	line = 171
	context = Context: null
	context level = -1 ]
-------------------------
All frames...

#0000 [exit     : sp(0) fp(0x700004a56cd0) pc(0)]
#0001 [stub     : sp(0x700004a56ce0) fp(0x700004a56cf8) pc(0x104682180)]
#0002 [dart     : sp(0x700004a56d08) fp(0x700004a56d80) pc(0x1089ed401) file:///Users/danny/Dev/Game/tool/test.dart_::_main__async_op ]
#0003 [dart     : sp(0x700004a56d90) fp(0x700004a56de0) pc(0x1089fb458) dart:async__RootZone@8048458_runUnary ]
#0004 [dart     : sp(0x700004a56df0) fp(0x700004a56e30) pc(0x1089fb005) dart:async__FutureListener@8048458_handleValue ]
#0005 [dart     : sp(0x700004a56e40) fp(0x700004a56ea8) pc(0x1089fac08) dart:async__Future@8048458__propagateToListeners@8048458_handleValueCallback ]
#0006 [dart     : sp(0x700004a56eb8) fp(0x700004a56f28) pc(0x1089f9c32) dart:async__Future@8048458__propagateToListeners@8048458 ]
#0007 [dart     : sp(0x700004a56f38) fp(0x700004a56f70) pc(0x1089f853a) dart:async__Future@8048458__complete@8048458 ]
#0008 [dart     : sp(0x700004a56f80) fp(0x700004a56fe8) pc(0x1089f7f1a) dart:async_Future_Future.delayed_<anonymous closure> ]
#0009 [dart     : sp(0x700004a56ff8) fp(0x700004a57038) pc(0x1089f7d34) dart:async_Timer__createTimer@8048458_<anonymous closure> ]
#0010 [dart     : sp(0x700004a57048) fp(0x700004a57078) pc(0x1089c9c7c) dart:core__Closure@0150898_call ]
#0011 [dart     : sp(0x700004a57088) fp(0x700004a57110) pc(0x1089f6da5) dart:isolate__Timer@1026248__runTimers@1026248 ]
#0012 [dart     : sp(0x700004a57120) fp(0x700004a57148) pc(0x1089f56c3) dart:isolate__Timer@1026248__handleMessage@1026248 ]
#0013 [dart     : sp(0x700004a57158) fp(0x700004a57190) pc(0x1089f5260) dart:isolate__Timer@1026248__handleMessage@1026248__handleMessage@1026248 ]
#0014 [dart     : sp(0x700004a571a0) fp(0x700004a571d0) pc(0x1089c9c7c) dart:core__Closure@0150898_call ]
#0015 [dart     : sp(0x700004a571e0) fp(0x700004a57208) pc(0x1089ea073) dart:isolate__RawReceivePortImpl@1026248__handleMessage@1026248 ]
#0016 [entry    : sp(0x700004a57218) fp(0x700004a57278) pc(0x1046815cc)]

===== CRASH =====
si_signo=Bus error: 10(10), si_code=2, si_addr=0x104640041
version=2.2.1-edge.22a843a23d6ab8112034a6743b98435bf5dde143 (Sat Apr 13 16:20:22 2019 +0000) on "macos_x64"
thread=10251, isolate=main(0x7fb0fa003c00)
  pc 0x0000000104640041 fp 0x0000700004a55e98 Unknown symbol
  pc 0x0000000102cc8607 fp 0x0000700004a55f40 dart::DartEntry::InvokeFunction(dart::Function const&, dart::Array const&, dart::Array const&, unsigned long)
  pc 0x0000000102cd15b0 fp 0x0000700004a55f80 dart::ActivationFrame::GetAsyncCompleterAwaiter(dart::Object const&)
  pc 0x0000000102cce60b fp 0x0000700004a56180 dart::Debugger::CollectAwaiterReturnStackTrace()
  pc 0x0000000102cdab58 fp 0x0000700004a562c0 dart::Debugger::PauseBreakpoint()
  pc 0x0000000102e1cebf fp 0x0000700004a56c90 dart::DRT_BreakpointRuntimeHandler(dart::NativeArguments)
  pc 0x0000000104681108 fp 0x0000700004a56cd0 Unknown symbol
  pc 0x0000000104682180 fp 0x0000700004a56cf8 Unknown symbol
  pc 0x00000001089ed401 fp 0x0000700004a56d80 Unknown symbol
  pc 0x00000001089fb458 fp 0x0000700004a56de0 Unknown symbol
  pc 0x00000001089fb005 fp 0x0000700004a56e30 Unknown symbol
  pc 0x00000001089fac08 fp 0x0000700004a56ea8 Unknown symbol
  pc 0x00000001089f9c32 fp 0x0000700004a56f28 Unknown symbol
  pc 0x00000001089f853a fp 0x0000700004a56f70 Unknown symbol
  pc 0x00000001089f7f1a fp 0x0000700004a56fe8 Unknown symbol
  pc 0x00000001089f7d34 fp 0x0000700004a57038 Unknown symbol
  pc 0x00000001089c9c7c fp 0x0000700004a57078 Unknown symbol
  pc 0x00000001089f6da5 fp 0x0000700004a57110 Unknown symbol
  pc 0x00000001089f56c3 fp 0x0000700004a57148 Unknown symbol
  pc 0x00000001089f5260 fp 0x0000700004a57190 Unknown symbol
  pc 0x00000001089c9c7c fp 0x0000700004a571d0 Unknown symbol
  pc 0x00000001089ea073 fp 0x0000700004a57208 Unknown symbol
  pc 0x00000001046815cc fp 0x0000700004a57278 Unknown symbol
  pc 0x0000000102cc8607 fp 0x0000700004a57320 dart::DartEntry::InvokeFunction(dart::Function const&, dart::Array const&, dart::Array const&, unsigned long)
  pc 0x0000000102ccb52c fp 0x0000700004a57380 dart::DartLibraryCalls::HandleMessage(dart::Object const&, dart::Instance const&)
  pc 0x0000000102cfcd2b fp 0x0000700004a57dc0 dart::IsolateMessageHandler::HandleMessage(dart::Message*)
  pc 0x0000000102d2d70e fp 0x0000700004a57e10 dart::MessageHandler::HandleMessages(dart::MonitorLocker*, bool, bool)
  pc 0x0000000102d2dd86 fp 0x0000700004a57e70 dart::MessageHandler::TaskCallback()
  pc 0x0000000102e5d57f fp 0x0000700004a57ea0 dart::ThreadPool::Worker::Loop()
  pc 0x0000000102e5d446 fp 0x0000700004a57ee0 dart::ThreadPool::Worker::Main(unsigned long)
  pc 0x0000000102dc0c4f fp 0x0000700004a57f10 dart::OSThread::GetMaxStackSize()
  pc 0x00007fff6ce742eb fp 0x0000700004a57f30 _pthread_body
  pc 0x00007fff6ce77249 fp 0x0000700004a57f50 _pthread_start
  pc 0x00007fff6ce7340d fp 0x0000700004a57f78 thread_start
-- End of DumpStackTrace
Exited (sigabrt)

(@a-siva @bkonyi)

@a-siva a-siva added the area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. label Apr 15, 2019
dart-bot pushed a commit that referenced this issue Apr 23, 2019
…flowgraph

Debugger will retrieve the saved context object when looking for IsAtAsyncJump(). The saved context object does not match the context level if setting breakpoint on "break" statement.
It is because when flowgraph builds break statement, DebugStepCheck was put after context object was restored to its parent. Then activation frame got the parent context when pausing at breakpoint.

Bug: #36622
Change-Id: I07508eb42ab102f9697797ef15f914de8bd1af65
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100087
Commit-Queue: Zichang Guo <zichangguo@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
@DanTup
Copy link
Collaborator Author

DanTup commented Apr 25, 2019

@zichangg Thanks, working fine in todays nightly 👍

@duzenko
Copy link

duzenko commented May 17, 2019

Did you release this yet? It's happening to me on 3.0.2

@DanTup
Copy link
Collaborator Author

DanTup commented May 17, 2019

@duzenko the fix is in the Dart SDK, not the VS Code extension. Looking at the commit above, it should be in 2.3.1-dev.0.0 which you can get from https://dart.dev/tools/sdk/archive if you don't mind using a Dev release in the meantime.

If you're using Flutter, you'll need to switch to the Flutter branch that includes a Dart SDK that has this fix (master will, though I'm not sure about dev).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.
Projects
None yet
Development

No branches or pull requests

4 participants