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

The compiler crashed: NoSuchMethodError: The getter 'boxedVariables' was called on null #48776

Closed
peerwaya opened this issue Apr 10, 2022 · 6 comments
Assignees
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. dart2js-crash type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-dart2js

Comments

@peerwaya
Copy link

peerwaya commented Apr 10, 2022

Run flutter build web --target lib/main.dart on my internal project, and the compiler crashes. This looks similar #47916

Log:

Flutter (Channel master, 2.13.0-0.0.pre.469, on macOS 12.2.1 21D62 darwin-arm, locale en-US)

Dart SDK 2.18.0-7.0.dev
Target dart2js failed: Exception: Warning: The 'dart2js' entrypoint script is deprecated, please use
'dart compile
           js' instead.
           org-dartlang-sdk:///lib/_internal/js_runtime/lib/core_patch.dart@5829+1:
           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 (2.18.0-7.0.dev), and
           
           * the entire message you see here (including the full stack trace
             below as well as the source location above).
           
           The compiler crashed: NoSuchMethodError: The getter 'boxedVariables' was called on null.
           Receiver: null
           Tried calling: boxedVariables
           #0      JsKernelToElementMap.makeRecordContainer
(package:compiler/src/js_model/element_map_impl.dart:1772:14)
           #1      ClosureDataBuilder.createClosureEntities.processModel
(package:compiler/src/js_model/closure.dart:331:23)
           #2      ClosureDataBuilder.createClosureEntities.<anonymous closure>.<anonymous closure>
           (package:compiler/src/js_model/closure.dart:391:9)
           #3      DiagnosticReporter.withCurrentElement
(package:compiler/src/diagnostics/diagnostic_listener.dart:145:15)
           #4      ClosureDataBuilder.createClosureEntities.<anonymous closure>
           (package:compiler/src/js_model/closure.dart:390:17)
           #5      _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:614:13)
           #6      ClosureDataBuilder.createClosureEntities (package:compiler/src/js_model/closure.dart:389:19)
           #7      JsClosedWorldBuilder.convertClosedWorld
(package:compiler/src/js_model/js_world_builder.dart:163:41)
           #8      JsBackendStrategy.createJClosedWorld (package:compiler/src/js_model/js_strategy.dart:176:52)
           #9      Compiler.closeResolution (package:compiler/src/compiler.dart:686:25)
           #10     Compiler.computeClosedWorld (package:compiler/src/compiler.dart:379:9)
           #11     Compiler.produceClosedWorld (package:compiler/src/compiler.dart:539:11)
           #12     Compiler.runSequentialPhases (package:compiler/src/compiler.dart:636:15)
           <asynchronous suspension>
           #13     Compiler.runInternal.<anonymous closure> (package:compiler/src/compiler.dart:307:7)
           <asynchronous suspension>
           #14     Compiler.runInternal (package:compiler/src/compiler.dart:306:5)
           <asynchronous suspension>
           #15     main (package:compiler/src/dart2js.dart:1409:3)
           <asynchronous suspension>
           
           
[   +7 ms] Compiling lib/main_dev.dart for the Web... (completed in 16.1s)
[        ] "flutter web" took 16,752ms.
[   +2 ms] Exception: Failed to compile application for the Web.
[        ] 
           #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
           #1      buildWeb (package:flutter_tools/src/web/compile.dart:81:5)
           <asynchronous suspension>
           #2      BuildWebCommand.runCommand (package:flutter_tools/src/commands/build_web.dart:112:5)
           <asynchronous suspension>
           #3      FlutterCommand.run.<anonymous closure>
(package:flutter_tools/src/runner/flutter_command.dart:1194:27)
           <asynchronous suspension>
           #4      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #5      CommandRunner.runCommand (package:args/command_runner.dart:209:13)
           <asynchronous suspension>
           #6      FlutterCommandRunner.runCommand.<anonymous closure>
           (package:flutter_tools/src/runner/flutter_command_runner.dart:281:9)
           <asynchronous suspension>
           #7      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #8      FlutterCommandRunner.runCommand
(package:flutter_tools/src/runner/flutter_command_runner.dart:229:5)
           <asynchronous suspension>
           #9      run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9)
           <asynchronous suspension>
           #10     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #11     main (package:flutter_tools/executable.dart:94:3)
           <asynchronous suspension>
           ```
@lrhn lrhn added the area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. label Apr 11, 2022
@fishythefish fishythefish added web-dart2js dart2js-crash type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) needs-info We need additional information from the issue author (auto-closed after 14 days if no response) labels Apr 11, 2022
@fishythefish
Copy link
Member

@peerwaya Can you provide a code sample which reproduces the issue?

/cc @rakudrama @johnniwinther

@sigmundch
Copy link
Member

Indeed, this looks very similar to #47916. The fix for that other issue landed in 5090974, which is supposed to be included in 2.18.0-7.0.dev

The error location above points at org-dartlang-sdk:///lib/_internal/js_runtime/lib/core_patch.dart@5829+1. It would be nice to see if we can stop emitting locations in this format. I believe we should these days have better context to provide a more legible error message. Anyhow, I believe the @5829 corresponds to a byte offset, and in that case this is pointing at a factory redirecting constructor of BigInt, here

factory BigInt.from(num value) = _BigIntImpl.from;

@peerwaya - is your code using BigInts? Do you also use constructor-tear offs. Maybe you can share some snippets using those?

@sigmundch
Copy link
Member

@peerwaya - no worries, I was able to reproduce this now locally.

Here is a minimal repro:

main() {
  BigInt.from;
}

@johnniwinther - I'm reassigning this to the CFE since it appears to be a kernel issue like the previous one. It is related, but I'm not quite sure what triggers it in this case. Could it be the fact that the target is external and later patched? I thought at first it could be a modularity issue, but the issue is still present if I compile both the SDK and the user code together in dart2js (commenting out when we load the platform.dill file)

@sigmundch sigmundch added area-front-end Use area-front-end for front end / CFE / kernel format related issues. and removed needs-info We need additional information from the issue author (auto-closed after 14 days if no response) area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. labels Apr 21, 2022
@johnniwinther johnniwinther self-assigned this Apr 22, 2022
@johnniwinther
Copy link
Member

A fix is the pipeline: https://dart-review.googlesource.com/c/sdk/+/242284

@sigmundch
Copy link
Member

@peerwaya - since you are in the master channel, this will likely be out in a release very soon (a matter of days). That said, if you want to workaround the issue, you only need to remove the use of tear-offs for constructors in classes defined in the dart SDK. For example, replace BigInt.from with (num x) => BigInt.from(x).

@peerwaya
Copy link
Author

Thanks for the update. Well done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. dart2js-crash 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