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

language/nnbd/late/covariant_instance_field_test fails with inlining disabled #56051

Closed
eseidel opened this issue Jun 19, 2024 · 4 comments
Closed
Assignees
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. P2 A bug or feature request we're likely to work on triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. triaged Issue has been triaged by sub team type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@eseidel
Copy link
Contributor

eseidel commented Jun 19, 2024

I suspect the answer may be "we don't support turning off inlining", but we were experimenting with such this week as part of attempting to fix other issues with Shorebird's linker. Turning off inlining causes only a few tests to fail.

This one is about language/nnbd/late/covariant_instance_field_test. I'll file others if needed/useful.

import 'package:expect/expect.dart';

class Foo {
  covariant late num a;
}

class Bar extends Foo {
  @override
  late int a;
}

void main() {
  Foo bar = Bar();
  bar.a = 2;
  Expect.equals(2, bar.a);
  Expect.throws(() {
    bar.a = 3.14 as dynamic;
    print('bar.a is now ${bar.a}');
  });
  print("success!");
}

Running in stock jit works fine:

dart test.dart
success!

But running in aot with inlining disabled fails:

DART_CONFIGURATION=DebugARM64 pkg/vm/tool/precompiler2 --deterministic --dedup_instructions --compiler-passes=-Inlining test.dart test.aot
xcodebuild/DebugARM64/dart_precompiled_runtime test.aot
bar.a is now -4609118966639786721
Unhandled exception:
Expect.throws fails: Did not throw
#0      Expect._fail (package:expect/expect.dart:881)
#1      Expect.throws (package:expect/expect.dart:766)
#2      main (file:///Users/eseidel/Documents/GitHub/unmodified-dart-sdk/sdk/test.dart:16)
#3      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:297)
#4      _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184)

My guess is that some part of the compiler's logic for control flow is now dependent on inlining optimizations for correctness.

@dart-github-bot
Copy link
Collaborator

Labels: area-vm, type-bug
Summary: The covariant_instance_field_test fails when inlining is disabled, causing a runtime error where a late covariant field is assigned a value of the wrong type. This issue may be related to the experimental linker changes made to Shorebird.

@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 Jun 19, 2024
@mraleph
Copy link
Member

mraleph commented Jun 20, 2024

@alexmarkov could you take a look if you have a moment? This is unexpected and might indicate a bug.

@alexmarkov alexmarkov self-assigned this Jun 21, 2024
@alexmarkov alexmarkov added P2 A bug or feature request we're likely to work on triaged Issue has been triaged by sub team labels Jun 21, 2024
@alexmarkov
Copy link
Contributor

@eseidel
Copy link
Contributor Author

eseidel commented Jun 21, 2024

We paused our efforts to disable inlining, but if we choose to look at disabling inlining again I will file any remaining issues we see. Thank you for the amazingly fast turn-around.

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. P2 A bug or feature request we're likely to work on triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. triaged Issue has been triaged by sub team type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

4 participants