Skip to content

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

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

Closed
Xyzcancer opened this issue Jul 7, 2022 · 9 comments
Labels
area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. closed-duplicate Closed in favor of an existing report needs-info We need additional information from the issue author (auto-closed after 14 days if no response) type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-dart2js

Comments

@Xyzcancer
Copy link

Hi, I've tried to build Chrome Extension with those commands, but both have failed with the same stacktrace

flutter build web --web-renderer html --csp
flutter build web

  • macOS 12.4 MacBookPro M1 Pro

  • Dart SDK version: 2.17.3 (stable) (Wed Jun 1 11:06:41 2022 +0200) on "macos_arm64"

  • 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.

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:1770:14)
#1 ClosureDataBuilder.createClosureEntities.processModel (package:compiler/src/js_model/closure.dart:329:23)
#2 ClosureDataBuilder.createClosureEntities.. (package:compiler/src/js_model/closure.dart:389:9)
#3 DiagnosticReporter.withCurrentElement (package:compiler/src/diagnostics/diagnostic_listener.dart:143:15)
#4 ClosureDataBuilder.createClosureEntities. (package:compiler/src/js_model/closure.dart:388:17)
#5 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:614:13)
#6 ClosureDataBuilder.createClosureEntities (package:compiler/src/js_model/closure.dart:387:19)
#7 JsClosedWorldBuilder.convertClosedWorld (package:compiler/src/js_model/js_world_builder.dart:161:41)
#8 JsBackendStrategy.createJClosedWorld (package:compiler/src/js_model/js_strategy.dart:174:52)
#9 Compiler.closeResolution (package:compiler/src/compiler.dart:684:25)
#10 Compiler.computeClosedWorld (package:compiler/src/compiler.dart:377:9)
#11 Compiler.produceClosedWorld (package:compiler/src/compiler.dart:537:11)
#12 Compiler.runSequentialPhases (package:compiler/src/compiler.dart:634:15)

#13 Compiler.runInternal. (package:compiler/src/compiler.dart:305:7)

#14 Compiler.runInternal (package:compiler/src/compiler.dart:304:5)

#15 main (package:compiler/src/dart2js.dart:1407:3)

@Xyzcancer
Copy link
Author

I've tried to update dart sdk to latest version 2.17.5

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:1770:14)
#1 ClosureDataBuilder.createClosureEntities.processModel (package:compiler/src/js_model/closure.dart:329:23)
#2 ClosureDataBuilder.createClosureEntities.. (package:compiler/src/js_model/closure.dart:389:9)
#3 DiagnosticReporter.withCurrentElement (package:compiler/src/diagnostics/diagnostic_listener.dart:143:15)
#4 ClosureDataBuilder.createClosureEntities. (package:compiler/src/js_model/closure.dart:388:17)
#5 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:614:13)
#6 ClosureDataBuilder.createClosureEntities (package:compiler/src/js_model/closure.dart:387:19)
#7 JsClosedWorldBuilder.convertClosedWorld (package:compiler/src/js_model/js_world_builder.dart:161:41)
#8 JsBackendStrategy.createJClosedWorld (package:compiler/src/js_model/js_strategy.dart:174:52)
#9 Compiler.closeResolution (package:compiler/src/compiler.dart:684:25)
#10 Compiler.computeClosedWorld (package:compiler/src/compiler.dart:377:9)
#11 Compiler.produceClosedWorld (package:compiler/src/compiler.dart:537:11)
#12 Compiler.runSequentialPhases (package:compiler/src/compiler.dart:634:15)

#13 Compiler.runInternal. (package:compiler/src/compiler.dart:305:7)

#14 Compiler.runInternal (package:compiler/src/compiler.dart:304:5)

#15 main (package:compiler/src/dart2js.dart:1407:3)

Error still there

@lrhn lrhn added web-dart2js area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. labels Jul 7, 2022
@fishythefish fishythefish added needs-info We need additional information from the issue author (auto-closed after 14 days if no response) type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Jul 8, 2022
@fishythefish
Copy link
Member

Thanks for filing an issue, @Xyzcancer. Do you have a code sample we can use to reproduce the issue?

@hacker1024
Copy link
Contributor

I'm having the same issue. It's very hard to narrow down the cause, as my project is very large.
Is there a way for us to work out what library or Element is causing the crash?

(Flutter 3.0.4, Dart 2.17.5, macOS 10.15)

💪 Building with sound null safety 💪

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@13695+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.17.5), 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:1770:14)
#1      ClosureDataBuilder.createClosureEntities.processModel (package:compiler/src/js_model/closure.dart:329:23)
#2      ClosureDataBuilder.createClosureEntities.<anonymous closure>.<anonymous closure> (package:compiler/src/js_model/closure.dart:389:9)
#3      DiagnosticReporter.withCurrentElement (package:compiler/src/diagnostics/diagnostic_listener.dart:143:15)
#4      ClosureDataBuilder.createClosureEntities.<anonymous closure> (package:compiler/src/js_model/closure.dart:388:17)
#5      _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:614:13)
#6      ClosureDataBuilder.createClosureEntities (package:compiler/src/js_model/closure.dart:387:19)
#7      JsClosedWorldBuilder.convertClosedWorld (package:compiler/src/js_model/js_world_builder.dart:161:41)
#8      JsBackendStrategy.createJClosedWorld (package:compiler/src/js_model/js_strategy.dart:174:52)
#9      Compiler.closeResolution (package:compiler/src/compiler.dart:684:25)
#10     Compiler.computeClosedWorld (package:compiler/src/compiler.dart:377:9)
#11     Compiler.produceClosedWorld (package:compiler/src/compiler.dart:537:11)
#12     Compiler.runSequentialPhases (package:compiler/src/compiler.dart:634:15)
<asynchronous suspension>
#13     Compiler.runInternal.<anonymous closure> (package:compiler/src/compiler.dart:305:7)
<asynchronous suspension>
#14     Compiler.runInternal (package:compiler/src/compiler.dart:304:5)
<asynchronous suspension>
#15     main (package:compiler/src/dart2js.dart:1407:3)
<asynchronous suspension>



Compiling lib/main.dart for the Web...                             40.2s
Exception: Failed to compile application for the Web.

@Xyzcancer
Copy link
Author

Thanks for filing an issue, @Xyzcancer. Do you have a code sample we can use to reproduce the issue?

I haven't)

I'm working on project covered by NDA, so to solve this I need to know how to find that piece of code.

@sigmundch
Copy link
Member

sigmundch commented Jul 11, 2022

@Xyzcancer - By chance is your code using BigInt.from as a constructor tear-off? If so, a quick workaround would be to stop using the tearoff feature, and use a hand-written closure instead: (x) => BigInt.from(x).

context: The cryptic error message you see is a byte-offset location in the SDK sources (we rarely see this kind of error message, but we should fix that to be less cryptic). Looking up that offset points to the definition of the BigInt.from constructor. That reminded me of a similar bug filed earlier this year: #48776. That bug ran into the issue I mentioned earlier. The underlying problem was in the common-front-end, and was fixed in 6fdaed9. This fix is part of Dart's beta (since 2.18.0-165.1.beta) and dev channels (since 2.18.0-57.0.dev), but it is not in the stable channel yet, so the version you are using (2.17.3) doesn't have it.

If it's possible for your team to use the Flutter beta releases, you should be able to confirm whether this issue was fixed. If not, the workaround (using a closure instead of a constructor-tearoff for BIgInt) should hopefully let you move past this error for the time being.

I'm tentatively closing this as a duplicate of #48776, but let me know if that's not accurate.

@sigmundch sigmundch added the closed-duplicate Closed in favor of an existing report label Jul 11, 2022
@hacker1024
Copy link
Contributor

hacker1024 commented Jul 12, 2022

Thanks. My crash was caused by the same issue - the offset in my log points to the patched Map.unmodifiable constructor, which I was indeed using as a tear-off.

@sigmundch
Copy link
Member

Thanks, good to know!

@Xyzcancer
Copy link
Author

Xyzcancer commented Oct 11, 2022 via email

@fishythefish
Copy link
Member

@Xyzcancer: The line org-dartlang-sdk:///lib/_internal/js_runtime/lib/core_patch.dart@5829+1 points to the BigInt.from constructor (byte offset 5829 in core_patch.dart). If you search your codebase for BigInt.from, you may be able to find where it's being used as a tearoff and replace it with (x) => BigInt.from(x). (Maybe search for BigInt.from not followed by (.)

As sigmundch mentioned above, the fix for this issue was included in Dart 2.18, so you may not need this workaround if you're able to update your Flutter installation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. closed-duplicate Closed in favor of an existing report needs-info We need additional information from the issue author (auto-closed after 14 days if no response) 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