8000 Dart compiler crash · Issue #60236 · dart-lang/sdk · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Dart compiler crash #60236

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

Open
rebaz94 opened this issue Mar 2, 2025 · 4 comments
Open

Dart compiler crash #60236

rebaz94 opened this issue Mar 2, 2025 · 4 comments
Assignees
Labels
area-dart-model For issues related to conformance 8000 to the language spec in the parser, compilers or the CLI analyzer. cfe-incremental-compiler Incremental compiler issue in the CFE legacy-area-front-end Legacy: Use area-dart-model instead. model-crashes Crashes in the analyzer or CFE P2 A bug or feature request we're likely to work on

Comments

@rebaz94
Copy link
rebaz94 commented Mar 2, 2025

The Dart compiler sometimes crashes when making simple changes to a factory constructor, such as introducing a local variable instead of returning directly or modifying a class parameter. The issue happens so frequently that I have to restart the Flutter app more than 10 times an hour.

Steps to Reproduce

Changing a factory constructor from:

factory MyModel.newInstance() {
  return MyModel();
}

to:

factory MyModel.newInstance() {
  final m = MyModel();
  return m;
}

causes the compiler to crash when saving the file.

Expected Behavior

The compiler should successfully recompile without crashing.

Actual Behavior

The Dart compiler crashes with the following error:

Unhandled exception:
Crash when compiling:
type 'Null' is not a subtype of type 'Library' in type cast

#0      ExtensionTypeDeclaration.enclosingLibrary (package:kernel/src/ast/declarations.dart:890)
#1      DillLibraryBuilder.finalizeExports (package:front_end/src/dill/dill_library_builder.dart:441)
#2      DillLibraryBuilder.ensureLoaded (package:front_end/src/dill/dill_library_builder.dart:202)
#3      DillExportNameSpace.ensureNameSpace (package:front_end/src/base/name_space.dart:311)
#4      LazyNameSpace._getables (package:front_end/src/base/name_space.dart:276)
#5      NameSpaceImpl.unfilteredNameIterator (package:front_end/src/base/name_space.dart:209)
#6      NameSpaceImpl.filteredNameIterator (package:front_end/src/base/name_space.dart:163)
#7      Import.finalizeImports (package:front_end/src/base/import.dart:95)
#8      SourceCompilationUnitImpl.addImportsToScope (package:front_end/src/source/source_compilation_unit.dart:834)
#9      SourceLibraryBuilder.addImportsToScope (package:front_end/src/source/source_library_builder.dart:650)
#10     SourceLoader.computeLibraryScopes (package:front_end/src/source/source_loader.dart:1547)
#11     KernelTarget.buildOutlines.<anonymous closure> (package:front_end/src/kernel/kernel_target.dart:506)
#12     withCrashReporting (package:front_end/src/base/crash.dart:139)
#13     KernelTarget.buildOutlines (package:front_end/src/kernel/kernel_target.dart:486)
#14     IncrementalCompiler.computeDelta.<anonymous closure> (package:front_end/src/base/incremental_compiler.dart:408)
<asynchronous suspension>
#15     CompilerContext.clear (package:front_end/src/base/compiler_context.dart:77)
<asynchronous suspension>
#16     IncrementalCompiler.compile (package:vm/incremental_compiler.dart:77)
<asynchronous suspension>
#17     FrontendCompiler.recompileDelta (package:frontend_server/frontend_server.dart:1030)
<asynchronous suspension>
#18     listenAndCompile.<anonymous closure> (package:frontend_server/frontend_server.dart:1481)
<asynchronous suspension>
the Dart compiler exited unexpectedly.
the Dart compiler exited unexpectedly.

Environment

  • Dart SDK Version: >=3.7.0 <4.0.0
  • OS: macOS
  • Editor/Tooling: IntelliJ
  • Workspace Setup:
    name: _
    publish_to: 'none'
    environment:
      sdk: ">=3.7.0 <4.0.0"
    
    workspace:
      - app
      - swifty_binder
      - swifty_model
      - swifty_localization
  • Additional Notes: This issue appears after enabling the workspace feature.
@rebaz94 rebaz94 changed the title Dart compiler crashe Dart compiler crash Mar 2, 2025
@mit-mit mit-mit added the legacy-area-front-end Legacy: Use area-dart-model instead. label Mar 3, 2025
@johnniwinther johnniwinther added model-crashes Crashes in the analyzer or CFE cfe-incremental-compiler Incremental compiler issue in the CFE area-dart-model For issues related to conformance to the language spec in the parser, compilers or the CLI analyzer. labels Mar 3, 2025
@johnniwinther johnniwinther added the P2 A bug or feature request we're likely to work on label Mar 3, 2025
@nate-thegrate
Copy link

I've been experiencing the same issue—I believe the error message I got is identical to the one above:

Unhandled exception:
Crash when compiling:
type 'Null' is not a subtype of type 'Library' in type cast

#0      ExtensionTypeDeclaration.enclosingLibrary (package:kernel/src/ast/declarations.dart:890)
#1      DillLibraryBuilder.finalizeExports (package:front_end/src/dill/dill_library_builder.dart:441)
#2      DillLibraryBuilder.ensureLoaded (package:front_end/src/dill/dill_library_builder.dart:202)
#3      DillExportNameSpace.ensureNameSpace (package:front_end/src/base/name_space.dart:311)
#4      LazyNameSpace._getables (package:front_end/src/base/name_space.dart:276)
#5      NameSpaceImpl.unfilteredNameIterator (package:front_end/src/base/name_space.dart:209)
#6      NameSpaceImpl.filteredNameIterator (package:front_end/src/base/name_space.dart:163)
#7      Import.finalizeImports (package:front_end/src/base/import.dart:95)
#8      SourceCompilationUnitImpl.addImportsToScope (package:front_end/src/source/source_compilation_unit.dart:834)
#9      SourceLibraryBuilder.addImportsToScope (package:front_end/src/source/source_library_builder.dart:650)
#10     SourceLoader.computeLibraryScopes (package:front_end/src/source/source_loader.dart:1547)
#11     KernelTarget.buildOutlines.<anonymous closure> (package:front_end/src/kernel/kernel_target.dart:506)
#12     withCrashReporting (package:front_end/src/base/crash.dart:139)
#13     KernelTarget.buildOutlines (package:front_end/src/kernel/kernel_target.dart:486)
#14     IncrementalCompiler.computeDelta.<anonymous closure> (package:front_end/src/base/incremental_compiler.dart:408)
<asynchronous suspension>
#15     CompilerContext.clear (package:front_end/src/base/compiler_context.dart:77)
<asynchronous suspension>
#16     IncrementalCompiler.compile (package:vm/incremental_compiler.dart:77)
<asynchronous suspension>
#17     FrontendCompiler.recompileDelta (package:frontend_server/frontend_server.dart:1030)
<asynchronous suspension>
#18     listenAndCompile.<anonymous closure> (package:frontend_server/frontend_server.dart:1481)
<asynchronous suspension>
the Dart compiler exited unexpectedly.
the Dart compiler exited unexpectedly.

I didn't have any factory constructors, but I noticed that if I stop using extension types, the crash no longer occurs.

@mraleph
Copy link
Member
mraleph commented Mar 28, 2025

@jensjoha did this fall through the cracks by chance?

@benthillerkus
Copy link
benthillerkus commented Apr 14, 2025

This started happening today.

Unhandled exception:
Crash when compiling:
type 'Null' is not a subtype of type 'Library' in type cast

#0      ExtensionTypeDeclaration.enclosingLibrary (package:kernel/src/ast/declarations.dart:890)
#1      DillLibraryBuilder.finalizeExports (package:front_end/src/dill/dill_library_builder.dart:441)
#2      DillLibraryBuilder.ensureLoaded (package:front_end/src/dill/dill_library_builder.dart:202)
#3      DillExportNameSpace.ensureNameSpace (package:front_end/src/base/name_space.dart:311)
#4      LazyNameSpace._getables (package:front_end/src/base/name_space.dart:276)
#5      NameSpaceImpl.unfilteredNameIterator (package:front_end/src/base/name_space.dart:209)
#6      NameSpaceImpl.filteredNameIterator (package:front_end/src/base/name_space.dart:163)
#7      Import.finalizeImports (package:front_end/src/base/import.dart:95)
#8      SourceCompilationUnitImpl.addImportsToScope (package:front_end/src/source/source_compilation_unit.dart:834)
#9      SourceLibraryBuilder.addImportsToScope (package:front_end/src/source/source_library_builder.dart:650)
#10     SourceLoader.computeLibraryScopes (package:front_end/src/source/source_loader.dart:1547)
#11     KernelTarget.buildOutlines.<anonymous closure> (package:front_end/src/kernel/kernel_target.dart:506)
#12     withCrashReporting (package:front_end/src/base/crash.dart:139)
#13     KernelTarget.buildOutlines (package:front_end/src/kernel/kernel_target.dart:486)
#14     IncrementalCompiler.computeDelta.<anonymous closure> (package:front_end/src/base/incremental_compiler.dart:408)
<asynchronous suspension>
#15     CompilerContext.clear (package:front_end/src/base/compiler_context.dart:77)
<asynchronous suspension>
#16     IncrementalCompiler.compile (package:vm/incremental_compiler.dart:77)
<asynchronous suspension>
#17     FrontendCompiler.compile (package:frontend_server/frontend_server.dart:642)
<asynchronous suspension>
#18     listenAndCompile.<anonymous closure> (package:frontend_server/frontend_server.dart:1401)
<asynchronous suspension>
2
the Dart compiler exited unexpectedly.
Flutter 3.29.2 • channel stable • https://github.com/flutter/flutter.git
Framework • revision c236373904 (5 weeks ago) • 2025-03-13 16:17:06 -0400
Engine • revision 18b71d647a
Tools • Dart 3.7.2 • DevTools 2.42.3

Dart SDK version: 3.7.2 (stable) (Tue Mar 11 04:27:50 2025 -0700) on "macos_arm64"

The app I'm trying to run (and that still worked on Friday) has this specified in the pubspec

environment:
  sdk: ^3.5.4

so it's not related to pub workspaces.

If I recall correctly I did briefly experiment last week with setting a higher version constraint, because I want to eventually move to pub workspaces.

Running flutter clean and then flutter run allowed me to work on the app again.

I've also created a new project with flutter create and that doesn't has the problem.

@Arenukvern
Copy link
Arenukvern commented Apr 25, 2025

For me, this error happend as combination of two things:

Project has mixed style of imports - relative and package - but seems it doesn’t relate to issue.
And project had constraint
sdk: ">=3.5.3 <4.0.0"
flutter: ">=3.24.3”
But after updating to
sdk: ">=3.7.0 <4.0.0”
the error still occur.

Every hot reload with small changes, for example add new property to row, or swap row to wrap, crashes the app.

Tested on android emulators, API 36 and API 35

[✓] Flutter (Channel stable, 3.29.3, on macOS 15.4.1 24E263 darwin-arm64, locale en-US) [296ms]
• Flutter version 3.29.3 on channel stable at /Users/antonio/fvm/versions/3.29.3
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision ea121f8859 (2 weeks ago), 2025-04-11 19:10:07 +0000
• Engine revision cf56914b32
• Dart version 3.7.2
• DevTools version 2.42.3

[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0) [1,294ms]
• Android SDK at /Users/antonio/Library/Android/sdk
• Platform android-36, build-tools 36.0.0
• Java binary at: /Applications/Android Studio Preview.app/Contents/jbr/Contents/Home/bin/java
This is the JDK bundled with the latest Android Studio installation on this machine.
To manually set the JDK path, use: flutter config --jdk-dir="path/to/jdk".
• Java version OpenJDK Runtime Environment (build 21.0.6+-13368085-b895.109)
• All Android licenses accepted.

[✓] Android Studio (version 2025.1.1) [10ms]
• Android Studio at /Applications/Android Studio Preview.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 21.0.6+-13368085-b895.109)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-dart-model For issues related to conformance to the language spec in the parser, compilers or the CLI analyzer. cfe-incremental-compiler Incremental compiler issue in the CFE legacy-area-front-end Legacy: Use area-dart-model instead. model-crashes Crashes in the analyzer or CFE P2 A bug or feature request we're likely to work on
Projects
None yet
Development

No branches or pull requests

8 participants
0