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 #124369

Closed
scottbisaillon opened this issue Apr 7, 2023 · 23 comments
Closed

Dart Compiler Exited Unexpectedly #124369

scottbisaillon opened this issue Apr 7, 2023 · 23 comments
Assignees
Labels
c: crash Stack traces logged to the console dependency: dart Dart team may need to help us found in release: 3.7 Found to occur in 3.7 found in release: 3.10 Found to occur in 3.10 has reproducible steps The issue has been confirmed reproducible and is ready to work on r: fixed Issue is closed as already fixed in a newer version t: hot reload Reloading code during "flutter run" tool Affects the "flutter" command-line tool. See also t: labels.

Comments

@scottbisaillon
Copy link

I am intermittently getting a crash when saving certain files in my Flutter project. I can't seem to narrow down what in a file causes the issue, but not all files do. Below is the trace when running flutter run --verbose.

Steps to Reproduce

  1. Run flutter application.
  2. Save file to trigger hot reload.

Expected results:
Does not crash.

Actual results:
Crashes on some files, but not all.

Logs
[  +90 ms] I/OpenGLRenderer( 6882): doUpdatePositionAsync is called and callVoidMethod
[+5588 ms] Skipping target: gen_localizations
[        ] Skipping target: gen_dart_plugin_registrant
[        ] Skipping target: _composite
[        ] complete
[  +35 ms] Scanned through 786 files in 22ms
[        ] Compiling dart to kernel with 1 updated files
[        ] Processing bundle.
[        ] <- recompile package:embers/main_development.dart e6e79330-77c0-4ace-8d88-83bc2f3ac084
[        ] package:embers/modules/recipe_tracker/view/routes/recipe_ingredients/recipe_ingredients_route.dart
[        ] <- e6e79330-77c0-4ace-8d88-83bc2f3ac084
[        ] Bundle processing done.
[  +57 ms] Updating files.
[ +114 ms] DevFS: Sync finished
[        ] Synced 0.0MB.
[ +326 ms] <- accept
[        ] reloaded 1 of 1777 libraries
[  +24 ms] Reassembling application
[ +364 ms] Hot reload performed in 909ms.
[        ] Reloaded 1 of 1777 libraries in 930ms (compile: 57 ms, reload: 327 ms, reassemble: 384 ms).
[+8713 ms] Skipping target: gen_localizations
[        ] Skipping target: gen_dart_plugin_registrant
[        ] Skipping target: _composite
[        ] complete
[  +29 ms] Scanned through 786 files in 21ms
[   +1 ms] Compiling dart to kernel with 1 updated files
[        ] Processing bundle.
[        ] <- recompile package:embers/main_development.dart 978105ef-4706-498b-a34a-47722dcfd31e
[        ] package:embers/modules/recipe_tracker/view/routes/recipe_ingredients/widgets/recipe_ingredient_dialog/cubit/recipe_ingredient_dialog_cubit.dart
[        ] <- 978105ef-4706-498b-a34a-47722dcfd31e
[        ] Bundle processing done.
[  +26 ms] Unhandled exception:
[        ] type 'Block' is not a subtype of type 'ReturnStatement' in type cast
[        ] #0      RedirectingFactoryBody.restoreFromDill (package:front_end/src/fasta/kernel/redirecting_factory_body.dart:121:39)
[        ] #1      DillLibraryBuilder._addClass (package:front_end/src/fasta/dill/dill_library_builder.dart:202:34)
[        ] #2      List.forEach (dart:core-patch/growable_array.dart:416:8)
[        ] #3      DillLibraryBuilder.ensureLoaded (package:front_end/src/fasta/dill/dill_library_builder.dart:108:21)
[        ] #4      LazyLibraryScope.ensureScope (package:front_end/src/fasta/dill/dill_library_builder.dart:57:21)
[        ] #5      LazyScope._local (package:front_end/src/fasta/scope.dart:722:5)
[        ] #6      new ScopeNameIterator (package:front_end/src/fasta/scope.dart:1017:28)
[        ] #7      Scope.unfilteredNameIterator (package:front_end/src/fasta/scope.dart:146:16)
[        ] #8      Scope.filteredNameIterator (package:front_end/src/fasta/scope.dart:182:40)
[        ] #9      LibraryBuilderImpl.localMembersNameIterator (package:front_end/src/fasta/builder/library_builder.dart:228:18)
[        ] #10     IncrementalCompiler._experimentalInvalidationFillReplacementMaps (package:front_end/src/fasta/incremental_compiler.dart:821:41)
[        ] #11     IncrementalCompiler._convertSourceLibraryBuildersToDill (package:front_end/src/fasta/incremental_compiler.dart:599:9)
[        ] #12     IncrementalCompiler.computeDelta.<anonymous closure> (package:front_end/src/fasta/incremental_compiler.dart:494:35)
[        ] <asynchronous suspension>
[        ] #13     IncrementalCompiler.compile (package:vm/incremental_compiler.dart:68:50)

[        ] <asynchronous suspension>
[        ] #14     FrontendCompiler.recompileDelta (package:frontend_server/frontend_server.dart:847:52)
[        ] <asynchronous suspension>

[  +49 ms] the Dart compiler exited unexpectedly.
[        ]
#0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
#1      DefaultResidentCompiler._compile.<anonymous closure> (package:flutter_tools/src/compile.dart:820:13)
#2      _rootRun (dart:async/zone.dart:1390:47)
#3      _CustomZone.run (dart:async/zone.dart:1300:19)
#4      _CustomZone.runGuarded (dart:async/zone.dart:1208:7)
#5      _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:392:13)
#6      _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:402:7)
#7      _BufferingStreamSubscription._close (dart:async/stream_impl.dart:291:7)
#8      _SinkTransformerStreamSubscription._close (dart:async/stream_transformers.dart:87:11)
#9      _EventSinkWrapper.close (dart:async/stream_transformers.dart:21:11)
#10     _StringAdapterSink.close (dart:convert/string_conversion.dart:251:11)
#11     _LineSplitterSink.close (dart:convert/line_splitter.dart:137:11)
#12     _SinkTransformerStreamSubscription._handleDone (dart:async/stream_transformers.dart:132:24)
#13     _rootRun (dart:async/zone.dart:1390:47)
#14     _CustomZone.run (dart:async/zone.dart:1300:19)
#15     _CustomZone.runGuarded (dart:async/zone.dart:1208:7)
#16     _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:392:13)
#17     _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:402:7)
#18     _BufferingStreamSubscription._close (dart:async/stream_impl.dart:291:7)
#19     _SinkTransformerStreamSubscription._close (dart:async/stream_transformers.dart:87:11)
#20     _EventSinkWrapper.close (dart:async/stream_transformers.dart:21:11)
#21     _StringAdapterSink.close (dart:convert/string_conversion.dart:251:11)
#22     _Utf8ConversionSink.close (dart:convert/string_conversion.dart:305:20)
#23     _ConverterStreamEventSink.close (dart:convert/chunked_conversion.dart:81:18)
#24     _SinkTransformerStreamSubscription._handleDone (dart:async/stream_transformers.dart:132:24)
#25     _rootRun (dart:async/zone.dart:1390:47)
#26     _CustomZone.run (dart:async/zone.dart:1300:19)
#27     _CustomZone.runGuarded (dart:async/zone.dart:1208:7)
#28     _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:392:13)
#29     _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:402:7)
#30     _BufferingStreamSubscription._close (dart:async/stream_impl.dart:291:7)
#31     _SyncStreamControllerDispatch._sendDone (dart:async/stream_controller.dart:782:19)
#32     _StreamController._closeUnchecked (dart:async/stream_controller.dart:637:7)
#33     _StreamController.close (dart:async/stream_controller.dart:630:5)
#34     _Socket._onData (dart:io-patch/socket_patch.dart:2362:21)
#35     _rootRunUnary (dart:async/zone.dart:1414:13)
#36     _CustomZone.runUnary (dart:async/zone.dart:1307:19)
#37     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1216:7)
#38     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#39     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#40     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:774:19)
#41     _StreamController._add (dart:async/stream_controller.dart:648:7)
#42     _StreamController.add (dart:async/stream_controller.dart:596:5)
#43     new _RawSocket.<anonymous closure> (dart:io-patch/socket_patch.dart:1884:35)
#44     _NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart:1327:18)
#45     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#46     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
#47     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:123:13)
#48     _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:193:5)

[        ] ensureAnalyticsSent: 0ms
[        ] Running 1 shutdown hook
[   +5 ms] Synced 0.0MB.
[        ] Shutdown hooks complete
[        ] the Dart compiler exited unexpectedly.
[        ]
#0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
#1      DefaultResidentCompiler._compile.<anonymous closure> (package:flutter_tools/src/compile.dart:820:13)
#2      _rootRun (dart:async/zone.dart:1390:47)
#3      _CustomZone.run (dart:async/zone.dart:1300:19)
#4      _CustomZone.runGuarded (dart:async/zone.dart:1208:7)
#5      _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:392:13)
#6      _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:402:7)
#7      _BufferingStreamSubscription._close (dart:async/stream_impl.dart:291:7)
#8      _SinkTransformerStreamSubscription._close (dart:async/stream_transformers.dart:87:11)
#9      _EventSinkWrapper.close (dart:async/stream_transformers.dart:21:11)
#10     _StringAdapterSink.close (dart:convert/string_conversion.dart:251:11)
#11     _LineSplitterSink.close (dart:convert/line_splitter.dart:137:11)
#12     _SinkTransformerStreamSubscription._handleDone (dart:async/stream_transformers.dart:132:24)
#13     _rootRun (dart:async/zone.dart:1390:47)
#14     _CustomZone.run (dart:async/zone.dart:1300:19)
#15     _CustomZone.runGuarded (dart:async/zone.dart:1208:7)
#16     _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:392:13)
#17     _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:402:7)
#18     _BufferingStreamSubscription._close (dart:async/stream_impl.dart:291:7)
#19     _SinkTransformerStreamSubscription._close (dart:async/stream_transformers.dart:87:11)
#20     _EventSinkWrapper.close (dart:async/stream_transformers.dart:21:11)
#21     _StringAdapterSink.close (dart:convert/string_conversion.dart:251:11)
#22     _Utf8ConversionSink.close (dart:convert/string_conversion.dart:305:20)
#23     _ConverterStreamEventSink.close (dart:convert/chunked_conversion.dart:81:18)
#24     _SinkTransformerStreamSubscription._handleDone (dart:async/stream_transformers.dart:132:24)
#25     _rootRun (dart:async/zone.dart:1390:47)
#26     _CustomZone.run (dart:async/zone.dart:1300:19)
#27     _CustomZone.runGuarded (dart:async/zone.dart:1208:7)
#28     _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:392:13)
#29     _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:402:7)
#30     _BufferingStreamSubscription._close (dart:async/stream_impl.dart:291:7)
#31     _SyncStreamControllerDispatch._sendDone (dart:async/stream_controller.dart:782:19)
#32     _StreamController._closeUnchecked (dart:async/stream_controller.dart:637:7)
#33     _StreamController.close (dart:async/stream_controller.dart:630:5)
#34     _Socket._onData (dart:io-patch/socket_patch.dart:2362:21)
#35     _rootRunUnary (dart:async/zone.dart:1414:13)
#36     _CustomZone.runUnary (dart:async/zone.dart:1307:19)
#37     _CustomZone.runUnaryGuarded (dart:async/zone.dart:1216:7)
#38     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#39     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#40     _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:774:19)
#41     _StreamController._add (dart:async/stream_controller.dart:648:7)
#42     _StreamController.add (dart:async/stream_controller.dart:596:5)
#43     new _RawSocket.<anonymous closure> (dart:io-patch/socket_patch.dart:1884:35)
#44     _NativeSocket.issueReadEvent.issue (dart:io-patch/socket_patch.dart:1327:18)
#45     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#46     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
#47     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:123:13)
#48     _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:193:5)

[        ] ensureAnalyticsSent: 0ms
[        ] Running 1 shutdown hook
[        ] Shutdown hooks complete
[        ] exiting with code 1
Exited (1)
[√] Flutter (Channel stable, 3.7.10, on Microsoft Windows [Version 10.0.22621.1413], locale en-US)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[√] Android Studio (version 2021.3)
[√] VS Code (version 1.77.0)
[√] Connected device (1 available)
[√] HTTP Host Availability

• No issues found!
@huycozy huycozy added the in triage Presently being triaged by the triage team label Apr 7, 2023
@huycozy
Copy link
Member

huycozy commented Apr 7, 2023

Hi @scottbisaillon
What is the target environment in which you see this issue? Does it only happen by Hot reload?

Also, could you please retry on the latest master channel to see if the issue still persists or not?

@huycozy huycozy added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Apr 7, 2023
@scottbisaillon
Copy link
Author

scottbisaillon commented Apr 7, 2023

Hi @huycozy,

Sorry for not including the target environment initially. Currently I am targeting a physical Samsung Galaxy S9+ running Android 10. I also just tried on an emulated pixel 3a running Android 13 with the same results. Incase its helpful, I am developing on a Windows 11 machine.

The issue persists on the latest master channel as well. This is the stacktrace, which appears to be the same:

Unhandled exception:
Crash when compiling:
type 'Block' is not a subtype of type 'ReturnStatement' in type cast

#0      RedirectingFactoryBody.restoreFromDill (package:front_end/src/fasta/kernel/redirecting_factory_body.dart:121:39)
#1      DillLibraryBuilder._addClass (package:front_end/src/fasta/dill/dill_library_builder.dart:202:34)

#2      List.forEach (dart:core-patch/growable_array.dart)
#3      DillLibraryBuilder.ensureLoaded (package:front_end/src/fasta/dill/dill_library_builder.dart:108:21)
#4      LazyLibraryScope.ensureScope (package:front_end/src/fasta/dill/dill_library_builder.dart:57:21)
#5      LazyScope._local (package:front_end/src/fasta/scope.dart:722:5)
#6      new ScopeNameIterator (package:front_end/src/fasta/scope.dart:1017:28)
#7      Scope.unfilteredNameIterator (package:front_end/src/fasta/scope.dart:146:16)
#8      Scope.filteredNameIterator (package:front_end/src/fasta/scope.dart:182:40)
#9      Import.finalizeImports (package:front_end/src/fasta/import.dart:78:60)
#10     SourceLibraryBuilder.addImportsToScope (package:front_end/src/fasta/source/source_library_builder.dart:1423:14)
#11     SourceLoader.computeLibraryScopes (package:front_end/src/fasta/source/source_loader.dart:1471:23)
#12     KernelTarget.buildOutlines.<anonymous closure> (package:front_end/src/fasta/kernel/kernel_target.dart:423:14)
#13     withCrashReporting (package:front_end/src/fasta/crash.dart:136:24)
#14     KernelTarget.buildOutlines (package:front_end/src/fasta/kernel/kernel_target.dart:406:12)
#15     IncrementalCompiler.computeDelta.<anonymous closure> (package:front_end/src/fasta/incremental_compiler.dart:408:59)
<asynchronous suspension>
#16     IncrementalCompiler.compile (package:vm/incremental_compiler.dart:68:50)
<asynchronous suspension>
#17     FrontendCompiler.recompileDelta (package:frontend_server/frontend_server.dart:847:52)
<asynchronous suspension>

2
the Dart compiler exited unexpectedly.

So far I have only gotten this issue when a Hot reload occurs after saving a file.

@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 Apr 7, 2023
@huycozy
Copy link
Member

huycozy commented Apr 7, 2023

Thanks for responding with more information!
Can you try to reproduce this issue on a newly created Flutter project? Or does it only happen on the current project?

Also, you may wanna try a temporary workaround at #114672 (comment) that may work for your case (similar case with hot reload but different stack trace)

@huycozy huycozy added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Apr 7, 2023
@scottbisaillon
Copy link
Author

Thank you for the suggestion! Unfortunately that workaround did not work in my case.

A new flutter project works without any issues. So far, this has only happened on the current project I am working on.

I just discarded my changes and reverted to a different commit on my project and things seem to be working, or I can't find a file that produces the issue when saved at least.

This isn't the first occurrence of the issue though. It has has happened previously, with what I believe was the same stacktrace, but I didn't record it at the time. Previously when it happened, running a subsequent flutter run command immediately crashed and required me to flutter clean first to be able to deploy to my device again.

This was not the case, however, with the occurrence I am reporting in this issue. I am able to deploy the app each time and it doesn't crash until I save certain files.

I will try and incrementally add my changes back and see if I can reproduce the issue in a more controlled manner.

@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 Apr 7, 2023
@huycozy huycozy added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Apr 7, 2023
@alexmarkov
Copy link
Contributor

/cc @johnniwinther

@scottbisaillon
Copy link
Author

I was able to reproduce this issue and consistently get it when saving a file with the following contents:

@freezed
class RecipeIngredientsEvent with _$RecipeIngredientsEvent {
  const factory RecipeIngredientsEvent.recipeIngredientAdded(
    RealmRecipeIngredient recipeIngredient,
  ) = _RecipeIngredientAdded;
}

RealmRecipeIngredient is a generated class using the Realm package.

The following file contents does not trigger the error:

abstract class RecipeIngredientsEvent {}

class RecipeIngredientAdded extends RecipeIngredientsEvent {
  RecipeIngredientAdded(this.recipeIngredient);

  final RealmRecipeIngredient recipeIngredient;
}

Is there something possibly not interacting well with generated code using other generated code? This seems to be the only concrete cause I can find.

This happens even when the code is generated prior to deploying the app to a device as well as using the watch command in build_runner while the app is running.

@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 Apr 8, 2023
@scottbisaillon
Copy link
Author

Some more data points that might help figure out what is going on.

The above freezed class is a part of:

part 'recipe_ingredients_bloc.freezed.dart';
part 'recipe_ingredients_event.dart';
part 'recipe_ingredients_state.dart';

class RecipeIngredientsBloc
    extends Bloc<RecipeIngredientsEvent, RecipeIngredientsState> {
  RecipeIngredientsBloc({
    List<RealmRecipeIngredient>? recipeIngredients,
  }) : super(
          _RecipeIngredientsState(
            recipeIngredients:
                recipeIngredients?.map((e) => ListItem(value: e)).toIList() ??
                    IList(),
          ),
        ) {
    on<_RecipeIngredientAdded>(_onRecipeIngredientAdded);
  }

  void _onRecipeIngredientAdded(
    _RecipeIngredientAdded event,
    Emitter<RecipeIngredientsState> emit,
  ) {
    emit(
      state.copyWith(
        recipeIngredients: state.recipeIngredients
            .add(ListItem(value: event.recipeIngredient)),
      ),
    );
  }
}

which also triggers the failure.

I think I have confirmed through trial and error that it is indeed the RealmRecipeIngredient generated class that is the issue.

Wrapping it with something like

class RealmRecipeIngredientWrapper {
  RealmRecipeIngredientWrapper(this.value);

  final RealmRecipeIngredient value;
}

and then using that value in the freezed class does not cause the error either.

I am not sure where this leaves this issue and whether or not its an actual bug, or just something to code around, perhaps until static metaprogramming is out.

@gnprice
Copy link
Member

gnprice commented Apr 8, 2023

When the Dart compiler is crashing, that is definitely a bug and something the Dart team will be interested in fixing.

I think the next thing you could do that would be most helpful for getting the issue fixed would be if you can make a small set of files you can share (ideally one small file) that reproduces the crash.

One strategy to do this would be: take just that group of files (including the generated files) and put them in a new project, and delete everything in those files that refers to other parts of your app. Then keep deleting as much as you can while still reproducing the problem.

It's also possible that someone will look at this on Monday and find that the stack trace you shared is enough to diagnose the problem. So you could wait to see if that's the case.

@huycozy huycozy added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Apr 10, 2023
@scottbisaillon
Copy link
Author

Here is a small repo that demonstrates the bug: https://github.com/scottbisaillon/flutter_test_app_bug_-124369.

Please let me know if there is anything else I can do.

@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 Apr 10, 2023
@huycozy
Copy link
Member

huycozy commented Apr 11, 2023

Thanks for providing a minimal sample code. I can reproduce the issue on the latest stable and master channels with a similar stack trace when performing Hot reload.

Labeling the issue for further investigation.

flutter doctor -v (stable and master)
[✓] Flutter (Channel stable, 3.7.10, on macOS 13.0.1 22A400 darwin-x64, locale en-VN)
    • Flutter version 3.7.10 on channel stable at /Users/huynq/Documents/GitHub/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 4b12645012 (2 days ago), 2023-04-03 17:46:48 -0700
    • Engine revision ec975089ac
    • Dart version 2.19.6
    • DevTools version 2.20.1

[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
    • Android SDK at /Users/huynq/Library/Android/sdk
    • Platform android-33, build-tools 32.0.0
    • ANDROID_HOME = /Users/huynq/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E222b
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)

[✓] IntelliJ IDEA Community Edition (version 2022.1.1)
    • IntelliJ at /Users/huynq/Library/Application Support/JetBrains/Toolbox/apps/IDEA-C/ch-0/221.5591.52/IntelliJ IDEA CE.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.77.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.60.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-x64     • macOS 13.0.1 22A400 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 111.0.5563.146

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!
[!] Flutter (Channel master, 3.10.0-3.0.pre.30, on macOS 13.0.1 22A400 darwin-x64, locale en-VN)
    • Flutter version 3.10.0-3.0.pre.30 on channel master at /Users/huynq/Documents/GitHub/flutter_master
    ! Warning: `flutter` on your path resolves to /Users/huynq/Documents/GitHub/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/huynq/Documents/GitHub/flutter_master. Consider adding /Users/huynq/Documents/GitHub/flutter_master/bin to the front of your path.
    ! Warning: `dart` on your path resolves to /Users/huynq/Documents/GitHub/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/huynq/Documents/GitHub/flutter_master. Consider adding /Users/huynq/Documents/GitHub/flutter_master/bin to the front of your path.
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 2cf8502589 (7 minutes ago), 2023-04-10 20:21:24 -0700
    • Engine revision 4a7f3f2a1f
    • Dart version 3.0.0 (build 3.0.0-427.0.dev)
    • DevTools version 2.23.1
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
    • Android SDK at /Users/huynq/Library/Android/sdk
    • Platform android-33, build-tools 32.0.0
    • ANDROID_HOME = /Users/huynq/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E222b
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)

[✓] IntelliJ IDEA Community Edition (version 2022.1.1)
    • IntelliJ at /Users/huynq/Library/Application Support/JetBrains/Toolbox/apps/IDEA-C/ch-0/221.5591.52/IntelliJ IDEA CE.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.77.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.62.0

[✓] Connected device (3 available)
    • SM T225 (mobile) • R9JT3004VRJ • android-arm64  • Android 13 (API 33)
    • macOS (desktop)  • macos       • darwin-x64     • macOS 13.0.1 22A400 darwin-x64
    • Chrome (web)     • chrome      • web-javascript • Google Chrome 112.0.5615.49

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.

@huycozy huycozy added tool Affects the "flutter" command-line tool. See also t: labels. dependency: dart Dart team may need to help us t: hot reload Reloading code during "flutter run" has reproducible steps The issue has been confirmed reproducible and is ready to work on found in release: 3.7 Found to occur in 3.7 found in release: 3.10 Found to occur in 3.10 c: crash Stack traces logged to the console and removed in triage Presently being triaged by the triage team labels Apr 11, 2023
@mraleph
Copy link
Member

mraleph commented Apr 11, 2023

@jensjoha can you take a look?

@jensjoha
Copy link
Contributor

Status: Reproduced without flutter and realm...

copybara-service bot pushed a commit to dart-lang/sdk that referenced this issue Apr 11, 2023
Redirecting factories are encoded as "return redirect(bla);",
but apparently the ffi transformation changes that and we crash.
This reproduces the error.

Bug: flutter/flutter#124369
Change-Id: Iecfc815071b69c7f84cc8cb03306732d72f42e3a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294540
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
@christopherfujino
Copy link
Member

@jensjoha can I assume this to you?

@jensjoha jensjoha self-assigned this Apr 12, 2023
copybara-service bot pushed a commit to dart-lang/sdk that referenced this issue Apr 13, 2023
…ories

A redirecting factory is normally encoded as something like

```
  static factory •({required self::HelperClass bar = #C1}) → self::Bar
    return new self::Foo::•(bar: bar);
```

which the CFE also expects to recreate its internal state when loading
a dill file.

The Finalizable transformation from FFI can change that to something
like:

```
  static factory •({required self::HelperClass bar = #C1}) → self::Bar {
    return block {
      final synthesized self::Foo :expressionValueWrappedFinalizable = new self::Foo::•(bar: bar);
      _in::reachabilityFence(bar);
    } =>:expressionValueWrappedFinalizable;
  }
```

though, which the CFE doesn't understand and subsequently crashes as
in flutter/flutter#124369

This CL makes the CFE understand this transformed version,
fixing the crash.

TEST=Existing tests; added incremental compiler test.

Change-Id: I5e7a5fc6201e4419e9ec1ca69d5522d5190f1f83
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294761
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
@jensjoha
Copy link
Contributor

This should now be fixed on the dart side.

@christopherfujino
Copy link
Member

This engine roll has the dart sdk fix: flutter/engine#41161

This hasn't rolled to the framework yet. Once it has, I will close this bug.

@scottbisaillon
Copy link
Author

I greatly appreciate the quickness this was looked into, thank you!

@christopherfujino
Copy link
Member

The fix should now be in the Flutter SDK master channel as of: 082227b. If you would like to know when this fix will reach an official Flutter release channel, please see: https://github.com/flutter/flutter/wiki/Where%27s-my-commit%3F.

@huycozy huycozy added the r: fixed Issue is closed as already fixed in a newer version label Apr 17, 2023
@fluttermaster
Copy link

hey this same error is happening with me now , and i update flutter 6 days ago. Hot reload is not working anymore for me, complier just crashes. Here is the stack-trace. how do i fix this ?

#0 RedirectingFactoryBody.restoreFromDill (package:front_end/src/fasta/kernel/redirecting_factory_body.dart:121:39)

#1 DillLibraryBuilder._addClass (package:front_end/src/fasta/dill/dill_library_builder.dart:202:34)
#2 List.forEach (dart:core-patch/growable_array.dart:416:8)
#3 DillLibraryBuilder.ensureLoaded (package:front_end/src/fasta/dill/dill_library_builder.dart:108:21)
#4 LazyLibraryScope.ensureScope (package:front_end/src/fasta/dill/dill_library_builder.dart:57:21)
#5 LazyScope._local (package:front_end/src/fasta/scope.dart:722:5)

#6 new ScopeNameIterator (package:front_end/src/fasta/scope.dart:1017:28)
#7 Scope.unfilteredNameIterator (package:front_end/src/fasta/scope.dart:146:16)
#8 Scope.filteredNameIterator (package:front_end/src/fasta/scope.dart:182:40)
#9 Import.finalizeImports (package:front_end/src/fasta/import.dart:78:60)
#10 SourceLibraryBuilder.addImportsToScope (package:front_end/src/fasta/source/source_library_builder.dart:1423:14)

#11 IncrementalCompiler.compileExpression. (package:front_end/src/fasta/incremental_compiler.dart:1986:22)
#12 CompilerContext.runInContext.. (package:front_end/src/fasta/compiler_context.dart:118:46)

@mraleph
Copy link
Member

mraleph commented Apr 24, 2023

@fluttermaster flutter clean.

@fluttermaster
Copy link

@mraleph
I mean i know i am noob but that's the first thing i did. That's how i am running my code , flutter clean and then flutter get and once the compiler crashes , repeat the above steps.

@mraleph
Copy link
Member

mraleph commented Apr 24, 2023

@fluttermaster if that does not help update to master channel of Flutter it will have a fix for the problem. If that does not help either then file a separate bug.

@nonameden
Copy link

Same happening for me, looking forward to see it be merged to stable =(

copybara-service bot pushed a commit to dart-lang/sdk that referenced this issue May 15, 2023
…ting factories

A redirecting factory is normally encoded as something like

```
  static factory •({required self::HelperClass bar = #C1}) → self::Bar
    return new self::Foo::•(bar: bar);
```

which the CFE also expects to recreate its internal state when loading
a dill file.

The Finalizable transformation from FFI can change that to something
like:

```
  static factory •({required self::HelperClass bar = #C1}) → self::Bar {
    return block {
      final synthesized self::Foo :expressionValueWrappedFinalizable = new self::Foo::•(bar: bar);
      _in::reachabilityFence(bar);
    } =>:expressionValueWrappedFinalizable;
  }
```

though, which the CFE doesn't understand and subsequently crashes as
in flutter/flutter#124369

This CL makes the CFE understand this transformed version,
fixing the crash.

Cherry-pick notes:
Technically pkg/front_end/testcases/incremental/ffi_03.yaml
and pkg/front_end/testcases/incremental/ffi_03.yaml.world.1.expect
were added in https://dart-review.googlesource.com/c/sdk/+/294540
(as a crash reproduction) and only modified in
https://dart-review.googlesource.com/c/sdk/+/294761 but naturally
included here.

TEST=Existing tests; added incremental compiler test.

Fixes: #52332
Cherry-pick: https://dart-review.googlesource.com/c/sdk/+/294761
Change-Id: Iae538fd36df9b014935003ac3410d1281c2e35f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302202
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Kevin Chisholm <kevinjchisholm@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
c: crash Stack traces logged to the console dependency: dart Dart team may need to help us found in release: 3.7 Found to occur in 3.7 found in release: 3.10 Found to occur in 3.10 has reproducible steps The issue has been confirmed reproducible and is ready to work on r: fixed Issue is closed as already fixed in a newer version t: hot reload Reloading code during "flutter run" tool Affects the "flutter" command-line tool. See also t: labels.
Projects
None yet
Development

No branches or pull requests

9 participants