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

NNBD. Dart crashes on late variables #39658

Closed
sgrekhov opened this issue Dec 5, 2019 · 6 comments
Closed

NNBD. Dart crashes on late variables #39658

sgrekhov opened this issue Dec 5, 2019 · 6 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. NNBD Issues related to NNBD Release vm-nnbd-unfork-sdk Label for all issues that need to be done before the nnbd sdk can be unforked

Comments

@sgrekhov
Copy link
Contributor

sgrekhov commented Dec 5, 2019

class C {
  num pi = 3.14;
  late num p1 = this.pi;
  late final p2 = this.pi;
}

main() {
  new C().p1;
  new C().p2;
}

Run this code in dart with --enable-experiment=non-nullable flag and there will be a crach! Tested on

Dart VM version: 2.7.0-dev.2.1 (Mon Dec 2 20:10:59 2019 +0100) on "windows_x64"
Dart VM version: 2.7.0-dev.2.1 (Unknown timestamp) on "linux_x64"

@a-siva a-siva added 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. labels Dec 5, 2019
@a-siva a-siva added the NNBD Issues related to NNBD Release label Dec 5, 2019
@liamappelbe
Copy link
Contributor

Interesting. This is only reproducible if the late variable is a double. Ints and classes work fine.

@liamappelbe
Copy link
Contributor

It seems that when doubles are unboxed it messes with the late field logic. So the fix is just to disable unboxing for late fields, like we do for final fields.

@sgrekhov
Copy link
Contributor Author

sgrekhov commented Dec 6, 2019

@liamappelbe, I have one more test that produces a CRASH on late variables, but without double values. It tests that "It is an error for a class with a const constructor to have a late final field". And dart --enable-experiment=non-nullable crashes on this code on both Windows and Linux.

class C {
  static late final int s = 42;
//       ^^^^
// [analyzer] unspecified
// [cfe] unspecified

  late final int i = 42;
//^^^^
// [analyzer] unspecified
// [cfe] unspecified
  const C();
}

main()  {
  C();
}

Does your fix fixes this issue as well? If need I can create a separate issue for this, just let me know

@sgrekhov
Copy link
Contributor Author

sgrekhov commented Dec 6, 2019

@liamappelbe One more crash on late for strings

class A {
  String s;
  A(this.s);
}

class C {
  A a = new A("Lily was here");
   late A a1 = this.a;
}

main() {
  new C().a1;
}

Is this a separate issue?

@liamappelbe
Copy link
Contributor

The first one sounds like an analyzer bug, so file a separate issue (other people are working on that part).

The second one works for me, with or without the fix in e20ff1e, so that's a separate issue. Can you try syncing to head and file a bug if it's reproducible?

@sgrekhov
Copy link
Contributor Author

There are no crash any longer for all of the cases mentioned above. Tested on Dart VM version: 2.8.0-dev.0.0 (Wed Dec 11 10:31:10 2019 +0100) on "windows_x64". Thank you.

@a-siva a-siva added the vm-nnbd-unfork-sdk Label for all issues that need to be done before the nnbd sdk can be unforked label Jan 16, 2020
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. NNBD Issues related to NNBD Release vm-nnbd-unfork-sdk Label for all issues that need to be done before the nnbd sdk can be unforked
Projects
None yet
Development

No branches or pull requests

3 participants