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

dart2js compiler failure on co19 test #42641

Open
sgrekhov opened this issue Jul 9, 2020 · 7 comments
Open

dart2js compiler failure on co19 test #42641

sgrekhov opened this issue Jul 9, 2020 · 7 comments
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. P3 A lower priority bug or feature request type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-dart2js

Comments

@sgrekhov
Copy link
Contributor

sgrekhov commented Jul 9, 2020

dart2js fails on the following co19 test
https://github.com/dart-lang/co19/blob/master/Language/Types/Interface_Types/subtype_t27.dart

Output is

/======================================================================================================================================\
| dart2js-hostasserts-strong-linux-x64-chrome:co19/Language/Types/Interface_Types/subtype_t27 is new and failed (Crash, expected Pass) |
\======================================================================================================================================/

--- Command "dart2js" (took 11.000630s):
DART_CONFIGURATION=ReleaseX64 sdk/bin/dart2js_developer --enable-experiment=non-nullable --enable-experiment=non-nullable --test-mode --packages=/b/s/w/ir/.packages /b/s/w/ir/tests/co19/src/Language/Types/Interface_Types/subtype_t27.dart --sound-null-safety --libraries-spec=sdk/lib/libraries.json --platform-binaries=out/ReleaseX64/ --out=/b/s/w/ir/out/ReleaseX64/generated_compilations/dart2js/tests_co19_src_Language_Types_Interface_Types_subtype_t27/subtype_t27.js

exit code:
253

stdout:
tests/co19/src/Language/Types/Interface_Types/subtype_t27.dart:
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 (build number could not be determined), and

* the entire message you see here (including the full stack trace
  below as well as the source location above).

The compiler crashed: Stack Overflow
#0      _StringBase._interpolate (dart:core-patch/string_patch.dart:841:3)
#1      JClass.toString (package:compiler/src/js_model/elements.dart:102:56)
#2      JsKernelToElementMap.checkFamily (package:compiler/src/js_model/element_map_impl.dart:727:48)
#3      JsKernelToElementMap.getThisType (package:compiler/src/js_model/element_map_impl.dart:985:12)
#4      JsElementEnvironment.getThisType (package:compiler/src/js_model/element_map_impl.dart:2221:23)
#5      InferrerEngine._hasCallType (package:compiler/src/inferrer/inferrer_engine.dart:664:57)
#6      InferrerEngine.registerCalledMember (package:compiler/src/inferrer/inferrer_engine.dart:926:11)
#7      KernelTypeGraphBuilder.handleStaticInvoke (package:compiler/src/inferrer/builder_kernel.dart:1257:22)
#8      KernelTypeGraphBuilder.handleConstructorInvoke (package:compiler/src/inferrer/builder_kernel.dart:1209:9)
#9      KernelTypeGraphBuilder.visitSuperInitializer (package:compiler/src/inferrer/builder_kernel.dart:344:5)
#10     SuperInitializer.accept (package:kernel/ast.dart:2557:45)
#11     KernelTypeGraphBuilder.visit (package:compiler/src/inferrer/builder_kernel.dart:258:24)
#12     List.forEach (dart:core-patch/growable_array.dart:313:8)
#13     KernelTypeGraphBuilder.visitConstructor (package:compiler/src/inferrer/builder_kernel.dart:288:23)
#14     Constructor.accept (package:kernel/ast.dart:1972:40)
#15     KernelTypeGraphBuilder.run (package:compiler/src/inferrer/builder_kernel.dart:258:24)
#16     InferrerEngine._computeMemberTypeInformation (package:compiler/src/inferrer/inferrer_engine.dart:630:20)
#17     InferrerEngine.analyze.<anonymous closure> (package:compiler/src/inferrer/inferrer_engine.dart:562:14)
#18     CompilerDiagnosticReporter.withCurrentElement (package:compiler/src/compiler.dart:743:15)
#19     InferrerEngine.analyze (package:compiler/src/inferrer/inferrer_engine.dart:561:15)
#20     KernelTypeGraphBuilder.visitSuperInitializer (package:compiler/src/inferrer/builder_kernel.dart:347:15)
#21     SuperInitializer.accept (package:kernel/ast.dart:2557:45)
#22     KernelTypeGraphBuilder.visit (package:compiler/src/inferrer/builder_kernel.dart:258:24)
#23     List.forEach (dart:core-patch/growable_array.dart:313:8)
#24     KernelTypeGraphBuilder.visitConstructor (package:compiler/src/inferrer/builder_kernel.dart:288:23)
#25     Constructor.accept (package:kernel/ast.dart:1972:40)
#26     KernelTypeGraphBuilder.run (package:compiler/src/inferrer/builder_kernel.dart:258:24)
#27     InferrerEngine._computeMemberTypeInformation (package:compiler/src/inferrer/inferrer_engine.dart:630:20)
#28     InferrerEngine.analyze.<anonymous closure> (package:compiler/src/inferrer/inferrer_engine.dart:562:14)
#29     CompilerDiagnosticReporter.withCurrentElement (package:compiler/src/compiler.dart:743:15)
#30     InferrerEngine.analyze (package:compiler/src/inferrer/inferrer_engine.dart:561:15)
#31     KernelTypeGraphBuilder.visitSuperInitializer (package:compiler/src/inferrer/builder_kernel.dart:347:15)
#32     SuperInitializer.accept (package:kernel/ast.dart:2557:45)
#33     KernelTypeGraphBuilder.visit (package:compiler/src/inferrer/builder_kernel.dart:258:24)
#34     List.forEach (dart:core-patch/growable_array.dart:313:8)
#35     KernelTypeGraphBuilder.visitConstructor (package:compiler/src/inferrer/builder_kernel.dart:288:23)
#36     Constructor.accept (package:kernel/ast.dart:1972:40)
#37     KernelTypeGraphBuilder.run (package:compiler/src/inferrer/builder_kernel.dart:258:24)
#38     InferrerEngine._computeMemberTypeInformation (package:compiler/src/inferrer/inferrer_engine.dart:630:20)
#39     InferrerEngine.analyze.<anonymous closure> (package:compiler/src/inferrer/inferrer_engine.dart:562:14)
#40     CompilerDiagnosticReporter.withCurrentElement (package:compiler/src/compiler.dart:743:15)
...
...
#8933   _CustomZone.runUnary (dart:async/zone.dart:1100:19)
#8934   _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
#8935   Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
#8936   Future._propagateToListeners (dart:async/future_impl.dart:725:32)
#8937   Future._completeWithValue (dart:async/future_impl.dart:529:5)
#8938   _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:40:15)
#8939   _completeOnAsyncReturn (dart:async-patch/async_patch.dart:311:13)
#8940   KernelTarget.buildComponent.<anonymous closure> (package:front_end/src/fasta/kernel/kernel_target.dart)
#8941   _rootRunUnary (dart:async/zone.dart:1198:47)
#8942   _CustomZone.runUnary (dart:async/zone.dart:1100:19)
#8943   _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
#8944   Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
#8945   Future._propagateToListeners (dart:async/future_impl.dart:725:32)
#8946   Future._completeWithValue (dart:async/future_impl.dart:529:5)
#8947   _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:40:15)
#8948   _completeOnAsyncReturn (dart:async-patch/async_patch.dart:311:13)
#8949   Loader.buildBodies (package:front_end/src/fasta/loader.dart)
#8950   _rootRunUnary (dart:async/zone.dart:1198:47)
#8951   _CustomZone.runUnary (dart:async/zone.dart:1100:19)
#8952   _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
#8953   Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
#8954   Future._propagateToListeners (dart:async/future_impl.dart:725:32)
#8955   Future._completeWithValue (dart:async/future_impl.dart:529:5)
#8956   _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:40:15)
#8957   _completeOnAsyncReturn (dart:async-patch/async_patch.dart:311:13)
#8958   SourceLoader.buildBody (package:front_end/src/fasta/source/source_loader.dart)
#8959   _rootRunUnary (dart:async/zone.dart:1198:47)
#8960   _CustomZone.runUnary (dart:async/zone.dart:1100:19)
#8961   _FutureListener.handleValue (dart:async/future_impl.dart:143:18)
#8962   Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45)
#8963   Future._propagateToListeners (dart:async/future_impl.dart:725:32)
#8964   Future._completeWithValue (dart:async/future_impl.dart:529:5)
#8965   Future._asyncCompleteWithValue.<anonymous closure> (dart:async/future_impl.dart:567:7)
#8966   _rootRun (dart:async/zone.dart:1190:13)
#8967   _CustomZone.run (dart:async/zone.dart:1093:19)
#8968   _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:1021:23)
#8969   _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#8970   _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#8971   _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
#8972   _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:169:5)

--- Re-run this test:
python tools/test.py -n dart2js-hostasserts-strong-linux-x64-chrome --dart2js-batch co19/Language/Types/Interface_Types/subtype_t27
@lrhn lrhn added area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-dart2js labels Jul 9, 2020
@lrhn
Copy link
Member

lrhn commented Jul 9, 2020

And that is why you don't use recursion on something where you can't control the depth!

@sigmundch
Copy link
Member

Indeed, we are using recursion while building the global inference graph when visiting super and redirecting constructor initializers. We do so in order to properly mark whether this is exposed indirectly. To remove this use of recursion we would need to instead do a quick second pass to propagate this information after the graph is built.

@sigmundch sigmundch added the P3 A lower priority bug or feature request label Jul 9, 2020
@rakudrama
Copy link
Member

I have just spend some time looking into this crash before finding this issue.
Doubling the stack size (by recompiling the VM) makes it pass.
This test is flaky, since changes to the VM can cause the stack frame size to change.
There is no VM command-line option to control the stack size.

@lrhn The Dart specification does not say much about limits to recursion. Have you considered specifying some minimum requirements for a conforming implementation, e.g. handling extends to a certain depth, e.g., 128? Perhaps the fault is not really with recursion, but the implementation of recursion with a fixed stack. There are language implementations where there is essentially no recursion limit that is separate from an overall memory limit. There are certainly many algorithms which are much easier to write with recursion, so supporting deeper recursion would improve programmer productivity for the subset of programmers that work with these algorithms.

@mraleph A VM command-line stack-size configuration would be very useful for debugging this kind of problem, and enabling this test to pass.

@sgrekhov Is there a version of this test with a slightly less deep class hierarchy? Is there a reason that this goes to C1026, rather than some other depth?

@sgrekhov
Copy link
Contributor Author

@rakudrama I'm afraid we don't have less deep version of this test. We do have test with the deep 3, but it's not the case. Here we check the corner case of extreme deep class hierarchy. But, it's not a problem to add 128 and 512 versions of the test. Do you want me to add these tests?
I don't think that depth of C1026 was choosen by any other reasons than simply some big number

copybara-service bot pushed a commit that referenced this issue Nov 26, 2021
The test is causing frequent CQ failures right now.

Bug: #42641
Change-Id: I46727cab95eb8da5feec7de860426e94d5875314
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221325
Auto-Submit: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
Reviewed-by: William Hesse <whesse@google.com>
@rakudrama
Copy link
Member

@sgrekhov A C500 version would be great.

I notice for many of the co19 tests that dart2js generates code like Expect_isTrue(true).
When this happens, the tests are testing dart2js compiler optimizations rather than runtime behaviour.
This is probably happening a lot for AOT too.
I wonder if it is worthwhile to try to augment the tests so that there are cases that are easy to optimize and cases that are impossible to optimize to increase coverage to both compile-time and run-time.

@rakudrama
Copy link
Member

The bot can't read well.

@rakudrama rakudrama reopened this Dec 2, 2021
@sgrekhov
Copy link
Contributor Author

sgrekhov commented Dec 3, 2021

@rakudrama I've added C500 deep test. Please see dart-lang/co19@0242ff0

I suspect that statements like Expect.isTrue(C500() is C); are optimized to Expect_isTrue(true). @rakudrama could you please confirm that? If so, then we should find all tests that have hints like hint - Unnecessary type check; the result is always 'true'. and add additional runtime checks there. I'll create a separate co19 issue for that

Good catch, thank you

UPD Created dart-lang/co19#1243

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. P3 A lower priority bug or feature request type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-dart2js
Projects
None yet
Development

No branches or pull requests

4 participants