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 crash when evaluating a named record field of a late variable #57048

Open
DanTup opened this issue Nov 7, 2024 · 3 comments
Open

VM crash when evaluating a named record field of a late variable #57048

DanTup opened this issue Nov 7, 2024 · 3 comments
Assignees
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. crash Process exits with SIGSEGV, SIGABRT, etc. An unhandled exception is not a crash. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) vm-debugger

Comments

@DanTup
Copy link
Collaborator

DanTup commented Nov 7, 2024

Given this code, and a breakpoint on the marked line:

void main() {
  late var x = getThing();
  print('test'); // Breakpoint here
}

({int? a}) getThing() => (a: 1);

If you try to evaluate x.a (which at this point isn't initialized, though I hoped it would trigger initialization), the VM crashes with this error:

Connecting to VM Service at ws://127.0.0.1:50164/irJz-9Fkt2A=/ws
Connected to the VM Service.
x.a
../../runtime\vm/object.h: 8533: error: Handle check failed: saw sentinel expected Instance
version=3.7.0-edge.22833d51daf9f5c893010f284fc2cfb2f5d293f1 (main) (Thu Nov 7 03:40:54 2024 +0000) on "windows_x64"
pid=9012, thread=6348, isolate_group=main(000001CA55C69AC0), isolate=main(000001CA55CDE270)
os=windows, arch=x64, comp=no, sim=no
isolate_instructions=7ff6436c9c00, vm_instructions=7ff6436c9c20
fp=6ff46fc0d8, sp=6ff46fc0d8, pc=7ff643971972
  pc 0x00007ff643971972 fp 0x0000006ff46fc0d8 Dart_DetectNullSafety+0x29f812
-- End of DumpStackTrace
  pc 0x0000000000000000 fp 0x0000006ff46fc7d0 sp 0x0000000000000000 [Stub] CallToRuntime
  pc 0x000001ca55583d37 fp 0x0000006ff46fc820 sp 0x0000006ff46fc7e0 [Stub] OneArgCheckInlineCache
  pc 0x000001ca55f3a065 fp 0x0000006ff46fc850 sp 0x0000006ff46fc830 [Unoptimized] :Eval
  pc 0x000001ca555830ff fp 0x0000006ff46fc970 sp 0x0000006ff46fc860 [Stub] InvokeDartCode
  pc 0x0000000000000000 fp 0x0000006ff46fedc0 sp 0x0000000000000000 [Stub] CallToRuntime
  pc 0x000001ca55583bb1 fp 0x0000006ff46fedf0 sp 0x0000006ff46fedd0 [Stub] UnoptStaticCallBreakpoint
  pc 0x000001ca55f37655 fp 0x0000006ff46fee30 sp 0x0000006ff46fee00 [Unoptimized] main
  pc 0x000001ca55f39fcb fp 0x0000006ff46fee58 sp 0x0000006ff46fee40 [Unoptimized] main
  pc 0x000001ca55f39f02 fp 0x0000006ff46feeb8 sp 0x0000006ff46fee68 [Unoptimized] [email protected]:call
  pc 0x000001ca55f38bae fp 0x0000006ff46feef8 sp 0x0000006ff46feec8 [Unoptimized] _delayEntrypointInvocation@1026248.<anonymous closure>
  pc 0x000001ca55f388d5 fp 0x0000006ff46fef60 sp 0x0000006ff46fef08 [Unoptimized] [email protected]:call
  pc 0x000001ca55f37820 fp 0x0000006ff46fefb8 sp 0x0000006ff46fef70 [Unoptimized] _RawReceivePort@1026248._handleMessage@1026248
  pc 0x000001ca555830ff fp 0x0000006ff46ff0e0 sp 0x0000006ff46fefc8 [Stub] InvokeDartCode
evaluateInFrame: (-32000) Bad state: The client closed with pending request "evaluateInFrame".

Exited (-1073740791).
  • Dart 3.7.0-edge.22833d51daf9f5c893010f284fc2cfb2f5d293f1 (main) (Thu Nov 7 03:40:54 2024 +0000) on "windows_x64"
  • on windows / "Windows 11 Pro" 10.0 (Build 22631)
  • locale is en-GB
@dart-github-bot
Copy link
Collaborator

Summary: The VM crashes when evaluating a named record field of a late variable that hasn't been initialized yet. This occurs when trying to access the a field of x in the debugger, even though x is declared as late and hasn't been assigned a value.

@dart-github-bot dart-github-bot added area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Nov 7, 2024
@devoncarew devoncarew removed the triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. label Nov 7, 2024
@a-siva
Copy link
Contributor

a-siva commented Nov 7, 2024

//cc @derekxu16

@a-siva
Copy link
Contributor

a-siva commented Nov 11, 2024

Per discussion in the CFE sync meeting the general conclusion was

  • We need to account for a number of scenarios with respect to the potential side effects that can occur if we choose to run the late field initializer when evaluating expressions
  • the most expedient fix for the issue is for the VM to recognize that the late variable is not initialized and issue an error stating 'expression evaluation involving uninitialized late variables is not supported'

@a-siva a-siva added the crash Process exits with SIGSEGV, SIGABRT, etc. An unhandled exception is not a crash. label Nov 11, 2024
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. crash Process exits with SIGSEGV, SIGABRT, etc. An unhandled exception is not a crash. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) vm-debugger
Projects
None yet
Development

No branches or pull requests

5 participants