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

A strange and easily reproducible problem in the AOT-compiled code. #55607

Closed
haodong404 opened this issue May 1, 2024 · 1 comment
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 triaged Issue has been triaged by sub team type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@haodong404
Copy link

Problem Code

Normally, the following code should print [2, 2, 10]. However, in practice, if I execute it using dart run, it prints the correct result [2, 2, 10]. But if I first compile it into AOT code using dart compile aot-snapshot and then run it using dartaotruntime, it prints [0, 0, 10], which is clearly an incorrect result.

List<int> encode() {
  int offset = 0;
  List<int> part = [0, 0, 0];

  for (int i = 0; i < 2; i++) {
    part[offset] = 2;
    offset++;
  }

  // Everything will be okay if without the line below.
  part[offset] = 10;

  // And everything will be okay if with the `print` line.
  // print(part);
  return part;
}

void main() {
  print(encode());
}

Dart Infomation

- Dart 3.3.2 (stable) (Tue Mar 19 20:44:48 2024 +0000) on "macos_arm64"
- on macos / Version 14.4.1 (Build 23E224)

Actually, I have tried the latest dev version (3.5.0-109.0.dev), and this issue still exists.

@mraleph mraleph added area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels May 1, 2024
@mraleph
Copy link
Member

mraleph commented May 1, 2024

I think it is a bug in DSE: it probably thinks that both of these stores are storing to the same place, but they are not - because offset is a phi. Can you look at this @alexmarkov?

@alexmarkov alexmarkov self-assigned this May 1, 2024
@a-siva a-siva added triaged Issue has been triaged by sub team P2 A bug or feature request we're likely to work on labels May 1, 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. P2 A bug or feature request we're likely to work on 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