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

Dart compiler exited unexpectedly after flutter upgrade #148611

Closed
gyuson opened this issue May 18, 2024 · 14 comments
Closed

Dart compiler exited unexpectedly after flutter upgrade #148611

gyuson opened this issue May 18, 2024 · 14 comments
Labels
a: error message Error messages from the Flutter framework dependency: dart Dart team may need to help us r: fixed Issue is closed as already fixed in a newer version team-tool Owned by Flutter Tool team tool Affects the "flutter" command-line tool. See also t: labels.

Comments

@gyuson
Copy link

gyuson commented May 18, 2024

Steps to reproduce

  1. Upgraded Flutter (3.22.0) and Dart (3.4.0)
  2. updated dependences

Ran into the following errors repeatedly, even after cleaning, fetching dependencies again, etc.

`Launching lib/main.dart on Pixel 7a in debug mode...
Unhandled exception:
Crash when compiling:
Concurrent modification during iteration: Instance(length:2) of '_GrowableList'.

#0      ListIterator.moveNext (dart:_internal/iterable.dart:348)
#1      BodyBuilder._unaliasTypeAliasedConstructorInvocations
(package:front_end/src/fasta/kernel/body_builder.dart:1640)
#2      BodyBuilder.performDelayedActions
(package:front_end/src/fasta/kernel/body_builder.dart:1755)
#3      SourceLoader.buildOutlineExpressions
(package:front_end/src/fasta/source/source_loader.dart:2820)
#4      KernelTarget.buildOutlines.<anonymous closure>
(package:front_end/src/fasta/kernel/kernel_target.dart:545)
<asynchronous suspension>
#5      withCrashReporting (package:front_end/src/fasta/crash.dart:133)
<asynchronous suspension>
#6      KernelTarget.buildOutlines (package:front_end/src/fasta/kernel/kernel_target.dart:415)
<asynchronous suspension>
#7      IncrementalCompiler.computeDelta.<anonymous closure>
(package:front_end/src/fasta/incremental_compiler.dart:367)
<asynchronous suspension>
#8      CompilerContext.clear (package:front_end/src/fasta/compiler_context.dart:139)
<asynchronous suspension>
#9      IncrementalCompiler.compile (package:vm/incremental_compiler.dart:77)
<asynchronous suspension>
#10     FrontendCompiler.compile (package:frontend_server/frontend_server.dart:617)
<asynchronous suspension>
#11     listenAndCompile.<anonymous closure>
(package:frontend_server/frontend_server.dart:1311)
<asynchronous suspension>
the Dart compiler exited unexpectedly.
the Dart compiler exited unexpectedly.`

Expected results

Expected the app to run on debug smoothly, both in the simulator and physical device. I only had the issue after I updated the SDKs.

Actual results

App not running as expected

Code sample

Code sample
[Paste your code here]

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[Paste your output here]
@gyuson
Copy link
Author

gyuson commented May 18, 2024

flutter doctor results:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.22.0, on macOS 14.4.1 23E224 darwin-arm64, locale en-SG)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.3)
[✓] VS Code (version 1.89.1)
[✓] Connected device (6 available)
! Error: Browsing on the local area network for Ghia’s Mini. Ensure the device is unlocked and attached with a cable or
associated with the same local area network as this Mac.
The device must be opted into Developer Mode to connect wirelessly. (code -27)
[✓] Network resources

• No issues found!

@justprodev
Copy link

Unhandled exception:
Crash when compiling:
Concurrent modification during iteration: Instance(length:2) of '_GrowableList'.

#0      ListIterator.moveNext (dart:_internal/iterable.dart:348)
#1      BodyBuilder._unaliasTypeAliasedConstructorInvocations (package:front_end/src/fasta/kernel/body_builder.dart:1640)
#2      BodyBuilder.performDelayedActions (package:front_end/src/fasta/kernel/body_builder.dart:1755)
#3      SourceLoader.buildOutlineExpressions (package:front_end/src/fasta/source/source_loader.dart:2820)
#4      KernelTarget.buildOutlines.<anonymous closure> (package:front_end/src/fasta/kernel/kernel_target.dart:545)
<asynchronous suspension>
#5      withCrashReporting (package:front_end/src/fasta/crash.dart:133)
<asynchronous suspension>```

@darshankawar darshankawar added the in triage Presently being triaged by the triage team label May 20, 2024
@darshankawar
Copy link
Member

darshankawar commented May 20, 2024

2. updated dependences

@gyuson Can you provide pubspec.yaml in which you updated dependencies ?

A similar issue was fixed last year #131415

Meanwhile, tagging @mraleph for thoughts on the reported error.

@darshankawar darshankawar added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label May 20, 2024
@gyuson
Copy link
Author

gyuson commented May 21, 2024

@darshankawar here is the pubspec.yaml

name: ##########
description: "##########"

Prevent accidental publishing to pub.dev.

publish_to: 'none'

version: 1.0.0+1

environment:
sdk: '>=3.2.3 <4.0.0'

dependencies:
flutter:
sdk: flutter
firebase_auth: ^4.17.4
firebase_core: ^2.24.2
get: ^4.6.6
get_storage: ^2.1.1
video_player: ^2.8.2
cloud_firestore: ^4.15.4
firebase_storage: ^11.6.5
google_sign_in: ^6.2.1
sign_in_with_apple: ^6.1.0
crypto: ^3.0.3
flutter_facebook_auth: ^6.0.4
intl: ^0.19.0
flutter_spinkit: ^5.2.0
flutter_svg: ^2.0.9
carousel_slider: ^4.2.1
sleek_circular_slider: ^2.0.1
screenshot: ^2.5.0
pdf: ^3.10.7
share_plus: ^9.0.0
path_provider: ^2.1.2
flutter_screenutil: ^5.9.0
snapping_bottom_sheet: ^1.0.4
web: ^0.5.1
shimmer: ^3.0.0
cached_network_image: ^3.3.1
infinite_carousel: ^1.1.1
flutter_local_notifications: ^17.0.0
timezone: ^0.9.2
webview_flutter: ^4.7.0
json_annotation: ^4.9.0

dev_dependencies:
flutter_test:
sdk: flutter
mockito: ^5.4.4
firebase_auth_mocks: ^0.13.0
google_sign_in_mocks: ^0.3.0
fake_cloud_firestore: ^2.4.9
build_runner: ^2.1.4
flutter_lints: ^4.0.0
json_serializable: ^6.8.0
integration_test:
sdk: flutter

flutter:
fonts:
- family: GeneralSans
fonts:
- asset: assets/fonts/GeneralSans-Regular.otf
- asset: assets/fonts/GeneralSans-Medium.otf
weight: 500
- asset: assets/fonts/GeneralSans-Semibold.otf
weight: 600
- family: PlayfairDisplay
fonts:
- asset: assets/fonts/PlayfairDisplay-Medium.ttf
- asset: assets/fonts/PlayfairDisplay-MediumItalic.ttf
style: italic

uses-material-design: true

Enable generation of localized Strings from arb files.

generate: true

assets:
- assets/images/
- assets/images/icons/
- assets/videos/

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label May 21, 2024
@justprodev
Copy link

TL;DR: In my case, the reason was that I was using deprecated MaterialState* classes. I replaced them with WidgetState and the problem went away.

But, to see the cause of this I applied dirty patch to dart-sdk (3.4.0):

patched body_builder.dart
diff --git a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
index cc3d5f29e9e..b779a3137f3 100644
--- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
@@ -1636,6 +1636,7 @@ class BodyBuilder extends StackListenerImpl
   void _unaliasTypeAliasedConstructorInvocations(
       List<TypeAliasedConstructorInvocation>
           typeAliasedConstructorInvocations) {
+    List<TypeAliasedConstructorInvocation> newInvocations = [];
     for (TypeAliasedConstructorInvocation invocation
         in typeAliasedConstructorInvocations) {
       assert(invocation.hasBeenInferred || isOrphaned(invocation),
@@ -1664,12 +1665,13 @@ class BodyBuilder extends StackListenerImpl
             isConst: invocation.isConst);
       }
       if (replacement == null) {
-        delayedTypeAliasedConstructorInvocations.add(invocation);
+        newInvocations.add(invocation);
       } else {
         invocation.parent?.replaceChild(invocation, replacement);
       }
     }
     typeAliasedConstructorInvocations.clear();
+    delayedTypeAliasedConstructorInvocations.addAll(newInvocations);
   }
 
   void _unaliasTypeAliasedFactoryInvocations(
@@ -1757,6 +1759,7 @@ class BodyBuilder extends StackListenerImpl
       if (delayedTypeAliasedConstructorInvocations.isNotEmpty) {
         for (ConstructorInvocation invocation
             in delayedTypeAliasedConstructorInvocations) {
+              print(invocation);
           internalProblem(
               fasta.templateInternalProblemUnhandled.withArguments(
                   invocation.target.name.text, 'performDelayedActions'),

Anyway, I think that Concurrent modification error should be avoided, even in cases like that.

Well, it would be great to show some kind of informative message.

@darshankawar
Copy link
Member

Thanks for the update. I'll keep the issue open on the reported behavior for team's attention.

@darshankawar darshankawar added dependency: dart Dart team may need to help us a: error message Error messages from the Flutter framework tool Affects the "flutter" command-line tool. See also t: labels. team-tool Owned by Flutter Tool team and removed in triage Presently being triaged by the triage team labels May 22, 2024
@mraleph
Copy link
Member

mraleph commented May 22, 2024

@johnniwinther seems like a CFE bug. I don't know if it is already fixed upstream or not.

@johnniwinther
Copy link

It looks like a CFE bug.

@gyuson
Copy link
Author

gyuson commented May 24, 2024

guys, thanks for picking this up. i've downgraded my flutter version in the meantime, and everything is working as it should. if you need any more details or specific information from my end to assist with the investigation or to reproduce the issue, please let me know. thanks!

copybara-service bot pushed a commit to dart-lang/sdk that referenced this issue May 27, 2024
Closes flutter/flutter#148611

Change-Id: Idb091df6d771f286428809326e65ac6203f09d49
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368301
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
@chloestefantsova
Copy link

I was able to reproduce the issue and have just landed the fix: dart-lang/sdk@991fbf4.

@a-siva
Copy link
Contributor

a-siva commented May 29, 2024

Can we close this issue as a fix has landed.

@darshankawar
Copy link
Member

Closing as fixed.

@darshankawar darshankawar added the r: fixed Issue is closed as already fixed in a newer version label May 30, 2024
@iostriz
Copy link

iostriz commented Jun 10, 2024

I'm still facing the same with 3.22.2, only iteration: Instance(length:7) of '_GrowableList'
(length:7 instead of 2).

@mraleph
Copy link
Member

mraleph commented Jun 10, 2024

@iostriz I don't think the fix was cherry picked into 3.22.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: error message Error messages from the Flutter framework dependency: dart Dart team may need to help us r: fixed Issue is closed as already fixed in a newer version team-tool Owned by Flutter Tool team tool Affects the "flutter" command-line tool. See also t: labels.
Projects
None yet
Development

No branches or pull requests

8 participants