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

Crash With Addition Assignment In Loop #54453

Closed
impure opened this issue Dec 26, 2023 · 4 comments
Closed

Crash With Addition Assignment In Loop #54453

impure opened this issue Dec 26, 2023 · 4 comments
Assignees
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-dart2js

Comments

@impure
Copy link

impure commented Dec 26, 2023

The following code crashes dartpad:

void main() {
  int counter = 0;
  for (int i = 0; i < 5; i++) {
      counter += counter;
  }
}

I originally encountered this error when building to Flutter Web after upgrading to version 3.16 of Flutter. It appears to be a bug in dart2js.

Console
Error compiling to JavaScript:
compile: file:///tmp/dartpadGDABKL/lib/main.dart:
Internal Error: The compiler crashed when compiling this element.

The compiler is broken.

When compiling the above element, the compiler crashed. It is not
possible to tell if this is caused by a problem in your program or
not. Regardless, the compiler should not crash.

The Dart team would greatly appreciate if you would take a moment to
report this problem at http://dartbug.com/new.

Please include the following information:

* the name and version of your operating system,

* the Dart SDK build number (3.2.3), and

* the entire message you see here (including the full stack trace
  below as well as the source location above).

The compiler crashed: Stack Overflow
#0      NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:542:3)
#1      NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#2      NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#3      NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#4      NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#5      NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#6      NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#7      NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#8      NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#9      NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#10     NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#11     NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#12     NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#13     NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#14     NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#15     NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#16     NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#17     NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#18     NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#19     NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#20     NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#21     NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#22     NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#23     NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#24     NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#25     NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#26     NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#27     NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#28     NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#29     NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#30     NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#31     NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#32     NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#33     NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#34     NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#35     NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#36     NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#37     NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#38     NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#39     NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#40     NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#41     NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#42     NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#43     NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
...
...
#12594  NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#12595  NegateValue.- (package:compiler/src/ssa/value_range_analyzer.dart:555:19)
#12596  AddValue.unary- (package:compiler/src/ssa/value_range_analyzer.dart:396:31)
#12597  VariableValue.- (package:compiler/src/ssa/value_range_analyzer.dart:306:12)
#12598  Value.min (package:compiler/src/ssa/value_range_analyzer.dart:85:24)
#12599  Range.union (package:compiler/src/ssa/value_range_analyzer.dart:599:15)
#12600  LoopUpdateRecognizer.run (package:compiler/src/ssa/value_range_analyzer.dart:1293:36)
#12601  SsaValueRangeAnalyzer.visitPhi (package:compiler/src/ssa/value_range_analyzer.dart:816:16)
#12602  HPhi.accept (package:compiler/src/ssa/nodes.dart:3112:47)
#12603  SsaValueRangeAnalyzer.visitBasicBlock.visit (package:compiler/src/ssa/value_range_analyzer.dart:765:33)
#12604  SsaValueRangeAnalyzer.visitBasicBlock (package:compiler/src/ssa/value_range_analyzer.dart:774:11)
#12605  HGraphVisitor.visitDominatorTree (package:compiler/src/ssa/nodes.dart:162:9)
#12606  SsaValueRangeAnalyzer.visitGraph (package:compiler/src/ssa/value_range_analyzer.dart:742:5)
#12607  SsaOptimizerTask.optimize.runPhase.<anonymous closure> (package:compiler/src/ssa/optimize.dart:71:46)
#12608  CompilerTask.measureSubtask (package:compiler/src/common/tasks.dart:181:35)
#12609  SsaOptimizerTask.optimize.runPhase (package:compiler/src/ssa/optimize.dart:71:7)
#12610  SsaOptimizerTask.optimize.<anonymous closure> (package:compiler/src/ssa/optimize.dart:134:14)
#12611  SsaOptimizerTask.optimize (package:compiler/src/ssa/optimize.dart:90:5)
#12612  SsaFunctionCompiler.compile (package:compiler/src/ssa/ssa.dart:93:15)
#12613  JsBackendStrategy.generateCode (package:compiler/src/js_model/js_strategy.dart:334:43)
#12614  Compiler.emptyQueue.<anonymous closure>.<anonymous closure>.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:compiler/src/compiler.dart:833:70)
#12615  CompilerTask.measureSubtask (package:compiler/src/common/tasks.dart:181:35)
#12616  Compiler.emptyQueue.<anonymous closure>.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:compiler/src/compiler.dart:833:32)
#12617  CompilerTask.measureSubtask (package:compiler/src/common/tasks.dart:181:35)
#12618  Compiler.emptyQueue.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:compiler/src/compiler.dart:831:28)
#12619  DiagnosticReporter.withCurrentElement (package:compiler/src/diagnostics/diagnostic_listener.dart:142:15)
#12620  Compiler.emptyQueue.<anonymous closure>.<anonymous closure> (package:compiler/src/compiler.dart:829:18)
#12621  CodegenEnqueuer._forEach (package:compiler/src/js_backend/enqueuer.dart:249:12)
#12622  CodegenEnqueuer.forEach (package:compiler/src/js_backend/enqueuer.dart:265:5)
#12623  Compiler.emptyQueue.<anonymous closure> (package:compiler/src/compiler.dart:825:16)
#12624  CompilerTask.measureSubtask (package:compiler/src/common/tasks.dart:181:35)
#12625  Compiler.emptyQueue (package:compiler/src/compiler.dart:824:14)
#12626  Compiler.processQueue.<anonymous closure> (package:compiler/src/compiler.dart:848:7)
#12627  CompilerTask.measureSubtask (package:compiler/src/common/tasks.dart:181:35)
#12628  Compiler.processQueue (package:compiler/src/compiler.dart:842:14)
#12629  Compiler.runCodegenEnqueuer (package:compiler/src/compiler.dart:545:5)
#12630  Compiler.runSequentialPhases (package:compiler/src/compiler.dart:763:27)
#12631  _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#12632  _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
#12633  _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
#12634  _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:185:5)

This is on Windows 10 on Edge but my MacBook Air encountered a similar problem when building to Flutter Web.

@TheScriptRailoth

This comment was marked as off-topic.

@parlough parlough added web-dart2js type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. labels Dec 26, 2023
@biggs0125 biggs0125 self-assigned this Dec 27, 2023
@biggs0125
Copy link

Thanks for filing this! We recently made some improvements to our analysis of variables updated within loops. It seems like some operations were not correctly updated along with these improvements.

Fix in progress: https://dart-review.googlesource.com/c/sdk/+/343800

@sigmundch
Copy link
Member

@biggs0125 @rakudrama - given this is causing a crash, should we cherry-pick this to the stable channel?

@biggs0125
Copy link

Seems reasonable, I'll start that process.

copybara-service bot pushed a commit that referenced this issue Jan 5, 2024
The MarkerValue class was added fairly recently: 404edd9

Bug: #54453
Change-Id: I10d327a24425cecb2f0b44c0ea04bafa4cbf0698
Cherry-pick: https://dart-review.googlesource.com/c/sdk/+/343800
Cherry-pick-request: #54494
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/344241
Commit-Queue: Nate Biggs <[email protected]>
Reviewed-by: Sigmund Cherem <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-dart2js
Projects
None yet
Development

No branches or pull requests

5 participants