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

BE building decides some code is opted in on its own, then compiler crashes with 'name' sent to null #43988

Closed
alanknight-wk opened this issue Oct 29, 2020 · 10 comments
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. dart2js-crash

Comments

@alanknight-wk
Copy link

alanknight-wk commented Oct 29, 2020

Dart SDK version: 2.12.0-edge.2259593f836cf975f8d9aa86b3134f0c8748acd7 (be) (Thu Oct 29 18:52:56 2020 +0000) on "macos_x64"

This is building a large package that's previously been built with 2.7.2, unmodified. None of this code has been opted in.
A large part of the way through building it starts giving messages for a couple of files like

[SEVERE] build_web_compilers:ddc on test/unit/dev_logging_test.ddc.module:
Error compiling dartdevc module:wdesk|test/unit/dev_logging_test.ddc.js

test/unit/dev_logging_test.dart:19:13: Error: Non-nullable variable 'sub' must be assigned before it can be used.
await sub?.cancel();
^^^

After two such files we then get
We're sorry, you've found a bug in our compiler.
You can report this bug at:
https://github.com/dart-lang/sdk/issues/labels/web-dev-compiler
Please include the information below in your report, along with
any other information that may help us track it down. Thanks!
-------------------- %< --------------------
dartdevc -k arguments: --kernel --dart-sdk-summary=/Users/alanknight/dart/dart-git/sdk/xcodebuild/ReleaseX64/dart-sdk/lib/_internal/ddc_sdk.dill --modules=amd --no-summarize -o packages/graph_ui/graph_form.ddc.js --source-map ...

NoSuchMethodError: The getter 'name' was called on null.
Receiver: null
Tried calling: name
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
#1      ProgramCompiler._emitSuperTarget (package:dev_compiler/src/kernel/compiler.dart:4848:41)
#2      ProgramCompiler.visitSuperPropertySet (package:dev_compiler/src/kernel/compiler.dart:4337:20)
#3      SuperPropertySet.accept (package:kernel/ast.dart:3404:44)
#4      ProgramCompiler._visitExpression (package:dev_compiler/src/kernel/compiler.dart:3481:20)
#5      ProgramCompiler.visitReturnStatement (package:dev_compiler/src/kernel/compiler.dart:4005:38)
#6      ReturnStatement.accept (package:kernel/ast.dart:6311:43)
#7      ProgramCompiler._visitStatement (package:dev_compiler/src/kernel/compiler.dart:3409:20)
#8      ProgramCompiler._emitFunctionScopedBody (package:dev_compiler/src/kernel/compiler.dart:3420:18)
#9      ProgramCompiler._emitSyncFunctionBody.<anonymous closure> (package:dev_compiler/src/kernel/compiler.dart:3228:17)
#10     ProgramCompiler._withLetScope (package:dev_compiler/src/kernel/compiler.dart:2156:25)
#11     ProgramCompiler._withCurrentFunction (package:dev_compiler/src/kernel/compiler.dart:3262:18)
#12     ProgramCompiler._emitSyncFunctionBody (package:dev_compiler/src/kernel/compiler.dart:3224:17)
#13     ProgramCompiler._emitFunction (package:dev_compiler/src/kernel/compiler.dart:3027:11)
#14     ProgramCompiler._emitMethodDeclaration (package:dev_compiler/src/kernel/compiler.dart:1766:12)
#15     ProgramCompiler._defineClass (package:dev_compiler/src/kernel/compiler.dart:970:13)
#16     ProgramCompiler._emitClassDeclaration (package:dev_compiler/src/kernel/compiler.dart:571:5)
#17     ProgramCompiler._emitClass (package:dev_compiler/src/kernel/compiler.dart:503:21)
#18     ProgramCompiler._declareBeforeUse (package:dev_compiler/src/kernel/compiler.dart:527:7)
#19     ProgramCompiler._emitInterfaceType (package:dev_compiler/src/kernel/compiler.dart:2662:5)
#20     ProgramCompiler._defineClass.emitClassRef (package:dev_compiler/src/kernel/compiler.dart:818:11)
#21     ProgramCompiler._defineClass (package:dev_compiler/src/kernel/compiler.dart:905:33)
#22     ProgramCompiler._emitClassDeclaration (package:dev_compiler/src/kernel/compiler.dart:571:5)
#23     ProgramCompiler._emitClass (package:dev_compiler/src/kernel/compiler.dart:503:21)
#24     ProgramCompiler._declareBeforeUse (package:dev_compiler/src/kernel/compiler.dart:527:7)
#25     ProgramCompiler._emitInterfaceType (package:dev_compiler/src/kernel/compiler.dart:2662:5)
#26     ProgramCompiler._defineClass.emitClassRef (package:dev_compiler/src/kernel/compiler.dart:818:11)
#27     ProgramCompiler._defineClass (package:dev_compiler/src/kernel/compiler.dart:905:33)
#28     ProgramCompiler._emitClassDeclaration (package:dev_compiler/src/kernel/compiler.dart:571:5)
#29     ProgramCompiler._emitClass (package:dev_compiler/src/kernel/compiler.dart:503:21)
#30     ProgramCompiler._declareBeforeUse (package:dev_compiler/src/kernel/compiler.dart:527:7)
#31     ProgramCompiler._emitInterfaceType (package:dev_compiler/src/kernel/compiler.dart:2662:5)
#32     ProgramCompiler._defineClass.emitClassRef (package:dev_compiler/src/kernel/compiler.dart:818:11)
#33     ProgramCompiler._defineClass (package:dev_compiler/src/kernel/compiler.dart:905:33)
#34     ProgramCompiler._emitClassDeclaration (package:dev_compiler/src/kernel/compiler.dart:571:5)
#35     ProgramCompiler._emitClass (package:dev_compiler/src/kernel/compiler.dart:503:21)
#36     ProgramCompiler._declareBeforeUse (package:dev_compiler/src/kernel/compiler.dart:527:7)
#37     ProgramCompiler._emitInterfaceType (package:dev_compiler/src/kernel/compiler.dart:2662:5)
#38     ProgramCompiler._defineClass.emitClassRef (package:dev_compiler/src/kernel/compiler.dart:818:11)
#39     ProgramCompiler._defineClass (package:dev_compiler/src/kernel/compiler.dart:905:33)
#40     ProgramCompiler._emitClassDeclaration (package:dev_compiler/src/kernel/compiler.dart:571:5)
#41     ProgramCompiler._emitClass (package:dev_compiler/src/kernel/compiler.dart:503:21)
#42     List.forEach (dart:core-patch/growable_array.dart:313:8)
#43     ProgramCompiler._emitLibrary (package:dev_compiler/src/kernel/compiler.dart:452:23)
#44     List.forEach (dart:core-patch/growable_array.dart:313:8)
#45     ProgramCompiler.emitModule (package:dev_compiler/src/kernel/compiler.dart:343:15)
#46     _compile (package:dev_compiler/src/kernel/command.dart:430:27)
<asynchronous suspension>
#47     compile (package:dev_compiler/src/kernel/command.dart:48:18)
#48     compile (package:dev_compiler/src/compiler/shared_command.dart:456:10)
#49     _CompilerWorker.performRequest.<anonymous closure> (file:///Users/alanknight/dart/dart-git/sdk/pkg/dev_compiler/bin/dartdevc.dart:82:13)
#50     _rootRun (dart:async/zone.dart:1190:13)
#51     _CustomZone.run (dart:async/zone.dart:1093:19)
#52     _runZoned (dart:async/zone.dart:1630:10)
#53     runZoned (dart:async/zone.dart:1550:10)
#54     _CompilerWorker.performRequest (file:///Users/alanknight/dart/dart-git/sdk/pkg/dev_compiler/bin/dartdevc.dart:80:24)
#55     AsyncWorkerLoop.run.<anonymous closure> (package:bazel_worker/src/worker/async_worker_loop.dart:35:41)
#56     _rootRun (dart:async/zone.dart:1190:13)
#57     _CustomZone.run (dart:async/zone.dart:1093:19)
#58     _runZoned (dart:async/zone.dart:1630:10)
#59     runZoned (dart:async/zone.dart:1550:10)
#60     AsyncWorkerLoop.run (package:bazel_worker/src/worker/async_worker_loop.dart:35:26)
<asynchronous suspension>
#61     main (file:///Users/alanknight/dart/dart-git/sdk/pkg/dev_compiler/bin/dartdevc.dart:31:57)
#62     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:307:32)
#63     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
@alanknight-wk
Copy link
Author

Someone pointed out 2.12's opt-in by default policy for the null-safety breaking change, which might explain the nullability errors. But it doesn't seem to. All of the files that it complains about are in the main package being compiled, which does have an SDK constraint, minimum 2.4.0. And so do both of the packages in which we get compile errors, of 2.7.0 and 2.7.1 respectively.

However, I notice that all of the files that it complains about are either in /web or /test directories, which suggests that that opt-in might not be respecting the package SDK constraint correctly for org-dartlang-app: URLs within the package. It seemed to do it for all three .dart files in that package's web directory, and for both tests in one particular test directory, but not in any others. And there were two occurrences of the compiler crash, both in dependencies.

Adding the language version comment to all of the problem files manually removes those errors, but the compiler still crashes.

@devoncarew devoncarew added area-front-end Use area-front-end for front end / CFE / kernel format related issues. dart2js-crash labels Oct 30, 2020
@johnniwinther
Copy link
Member

We seem to have two problems:

  1. the null access in relation to the compile-time error
  2. the failure to opt-out files in /web or /test

I'll look into 1.

@jakemac53 Do you know how the compiler is invoked in this setting? If we synthesize urls with the org-dartlang-app scheme then the resolution of package_config.json might not work - either because package_config.json cannot be found or because it doesn't specifiy org-dartlang-app as the root location for the packages.

@johnniwinther
Copy link
Member

@alanknight-wk For 1. did the compilation output any other errors that the one at test/unit/dev_logging_test.dart:19:13 ? Given the stacktrace for the crash it looks like an unresolved super access like super.foo = 42 where foo is unknown.

@johnniwinther
Copy link
Member

Further investigating 1. it seems that the CFE sometimes generates a forwarding stub with no target. This is very dependent on the particular hierarchy and is hard to reproduce. I've managed to reproduce simpler case that would not have caused the crash in dev_compiler. @alanknight-wk If you can make a repro of the hierarchy that triggers the crash it would be much appreciated.

@jakemac53
Copy link
Contributor

As far as I am aware build_web_compilers does properly support web and test dirs - we create a special package_config.json file which has org-dartlang-app style uris for all packages in order to make the output hermetic across machines.

This was implemented for null safety though, so you would need a new-ish build_web_compilers to get that functionality, and it definitely did not work for a while in dart2js at least.

@alanknight-wk
Copy link
Author

The dev_logging_test error was an instance of 2, treating the files in /test of the main package as package-less and therefore opted-in.

There were two instances of the compiler crash. They are two different files, but look similar - both occur in emitSuperTarget. One of the files is just a lot of re-exports, but the other one is code and only contains one super call, of the form

  @override
  get defaultProps => (newProps()
    ..addProps(super.defaultProps)
    ..readOnly = false
  );

I'll see if I can reproduce that with a smaller example.

@johnniwinther
Copy link
Member

If the underlying cause the the forwarding stubs without target the might not be any super call in the user code - making the culprit so much harder to find!

@alanknight-wk
Copy link
Author

As far as I am aware build_web_compilers does properly support web and test dirs - we create a special package_config.json file which has org-dartlang-app style uris for all packages in order to make the output hermetic across machines.

This was implemented for null safety though, so you would need a new-ish build_web_compilers to get that functionality, and it definitely did not work for a while in dart2js at least.

OK, so it seems likely that upgrading the version of build_runner it's using might address issue 2. I hadn't changed anything about the pubspec. Upgrading to analyzer 0.40.5 seems to break built_value, but analyzer 0.40.1 combined with bleeding edge build_runner does not give those nullability errors.

dart-bot pushed a commit that referenced this issue Nov 3, 2020
In response to #43988

Change-Id: I3aa73a073b275b634b679bebfa2bf2ed9c292074
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170087
Reviewed-by: Jens Johansen <[email protected]>
Commit-Queue: Johnni Winther <[email protected]>
@johnniwinther
Copy link
Member

I've landed https://dart-review.googlesource.com/c/sdk/+/170087 in the Dart repo. I removes the failure that I could reproduce. @alanknight-wk can you verify that it fixes the crash?

@alanknight-wk
Copy link
Author

Yes, that fixes it.

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
Projects
None yet
Development

No branches or pull requests

4 participants