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

[kernel] Stack overflow in kernel from F-bound quantification #31810

Closed
MichaelRFairhurst opened this issue Jan 9, 2018 · 6 comments
Closed
Assignees
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. crash Process exits with SIGSEGV, SIGABRT, etc. An unhandled exception is not a crash. front-end-kernel P2 A bug or feature request we're likely to work on

Comments

@MichaelRFairhurst
Copy link
Contributor

An analyzer test which was previously disabled on accident tested this:

abstract class A<T extends A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A<A>>>>>>>>>>>>>>>>>>>>>{}

Which revealed that in CFE mode, this happens:

  Stack Overflow
  #0      new _FixedSizeArrayIterator (dart:core-patch/dart:core/array.dart:199)
  #1      KernelClassBuilder.buildTypeArguments (package:front_end/src/fasta/kernel/kernel_class_builder.dart:133:9)
  #2      KernelClassBuilder.buildType (package:front_end/src/fasta/kernel/kernel_class_builder.dart:125:23)
  #3      KernelClassBuilder.buildTypeArguments (package:front_end/src/fasta/kernel/kernel_class_builder.dart:63:23)
  #4      KernelClassBuilder.buildType (package:front_end/src/fasta/kernel/kernel_class_builder.dart:125:23)
  #5      KernelClassBuilder.buildTypeArguments (package:front_end/src/fasta/kernel/kernel_class_builder.dart:63:23)
  #6      KernelClassBuilder.buildType (package:front_end/src/fasta/kernel/kernel_class_builder.dart:125:23)
  #7      KernelClassBuilder.buildTypeArguments (package:front_end/src/fasta/kernel/kernel_class_builder.dart:63:23)
  #8      KernelClassBuilder.buildType (package:front_end/src/fasta/kernel/kernel_class_builder.dart:125:23)
  #9      KernelClassBuilder.buildTypeArguments (package:front_end/src/fasta/kernel/kernel_class_builder.dart:63:23)
  #10     KernelClassBuilder.buildType (package:front_end/src/fasta/kernel/kernel_class_builder.dart:125:23)
  #11     KernelClassBuilder.buildTypeArguments (package:front_end/src/fasta/kernel/kernel_class_builder.dart:63:23)
  #12     KernelClassBuilder.buildType (package:front_end/src/fasta/kernel/kernel_class_builder.dart:125:23)
  #13     KernelClassBuilder.buildTypeArguments (package:front_end/src/fasta/kernel/kernel_class_builder.dart:63:23)
  ...
  ...
  #12627  _rootRun (dart:async/zone.dart)
  #12628  _CustomZone.run (dart:async/zone.dart)
  #12629  _CustomZone.runGuarded (dart:async/zone.dart:923)
  #12630  _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:963)
  #12631  _microtaskLoop (dart:async/schedule_microtask.dart:41)
  #12632  _startMicrotaskLoop (dart:async/schedule_microtask.dart:50)
  #12633  _Timer._runTimers (dart:isolate-patch/dart:isolate/timer_impl.dart:376)
  #12634  _Timer._handleMessage (dart:isolate-patch/dart:isolate/timer_impl.dart:401)
  #12635  _RawReceivePortImpl._handleMessage (dart:isolate-patch/dart:isolate/isolate_patch.dart:163)
  
  package:analyzer/src/dart/analysis/driver.dart 1256:9              AnalysisDriver._computeAnalysisResult.<fn>
  package:front_end/src/base/performance_logger.dart 52:21           PerformanceLog.runAsync
  package:analyzer/src/dart/analysis/driver.dart 1183:20             AnalysisDriver._computeAnalysisResult
  package:analyzer/src/dart/analysis/driver.dart 879:19              AnalysisDriver.performWork
  package:analyzer/src/dart/analysis/driver.dart 1887:24             AnalysisDriverScheduler._run
  package:analyzer/src/dart/analysis/driver.dart 1830:5              AnalysisDriverScheduler.start
  test/generated/resolver_test_case.dart 707:17                      ResolverTestCase.resetWith
  test/generated/resolver_test_case.dart 656:5                       ResolverTestCase.reset
  test/generated/resolver_test_case.dart 809:5                       ResolverTestCase.setUp
  dart:mirrors-patch/dart:mirrors/mirrors_impl.dart 531              _LocalInstanceMirror._invoke
  dart:mirrors-patch/dart:mirrors/mirrors_impl.dart 527              _LocalInstanceMirror.invoke
  dart:mirrors-patch/dart:mirrors/mirrors_impl.dart 555              _LocalClosureMirror.apply
  package:test_reflective_loader/test_reflective_loader.dart 215:32  _invokeSymbolIfExists
  package:test_reflective_loader/test_reflective_loader.dart 242:10  _runTest
  package:test_reflective_loader/test_reflective_loader.dart 126:18  defineReflectiveTests.<fn>.<fn>
  package:test/src/backend/declarer.dart 139:19                      Declarer.test.<fn>.<fn>
  package:test/src/backend/invoker.dart 206:15                       Invoker.waitForOutstandingCallbacks.<fn>
  dart:async/zone.dart 1124                                          _rootRun
  dart:async/zone.dart 1021                                          _CustomZone.run
  dart:async/zone.dart 1499                                          runZoned
  package:test/src/backend/invoker.dart 203:5                        Invoker.waitForOutstandingCallbacks
  package:test/src/backend/declarer.dart 137:29                      Declarer.test.<fn>
  package:test/src/backend/invoker.dart 351:23                       Invoker._onRun.<fn>.<fn>.<fn>
  dart:async/future.dart 174                                         new Future.<fn>
  package:stack_trace/src/stack_zone_specification.dart 189:15       StackZoneSpecification._run
  package:stack_trace/src/stack_zone_specification.dart 99:48        StackZoneSpecification._registerCallback.<fn>
  dart:async/zone.dart 1120                                          _rootRun
  dart:async/zone.dart 1021                                          _CustomZone.run
  dart:async/zone.dart 923                                           _CustomZone.runGuarded
  dart:async/zone.dart 963                                           _CustomZone.bindCallbackGuarded.<fn>
  package:stack_trace/src/stack_zone_specification.dart 189:15       StackZoneSpecification._run
  package:stack_trace/src/stack_zone_specification.dart 99:48        StackZoneSpecification._registerCallback.<fn>
  dart:async/zone.dart 1124                                          _rootRun
  dart:async/zone.dart 1021                                          _CustomZone.run
  dart:async/zone.dart 947                                           _CustomZone.bindCallback.<fn>
  dart:async-patch/dart:async/timer_patch.dart 21                    Timer._createTimer.<fn>
  dart:isolate-patch/dart:isolate/timer_impl.dart 367                _Timer._runTimers
  dart:isolate-patch/dart:isolate/timer_impl.dart 401                _Timer._handleMessage
  dart:isolate-patch/dart:isolate/isolate_patch.dart 163             _RawReceivePortImpl._handleMessage
  ===== asynchronous gap ===========================
  dart:async/future_impl.dart 22                                     _Completer.completeError
  package:analyzer/src/dart/analysis/driver.dart                     AnalysisDriver._computeAnalysisResult.<fn>
  ===== asynchronous gap ===========================
  dart:async/zone.dart 1062                                          _CustomZone.registerBinaryCallback
  dart:async-patch/dart:async/async_patch.dart 49                    _asyncErrorWrapperHelper
  package:analyzer/src/dart/analysis/driver.dart 1183:75             AnalysisDriver._computeAnalysisResult.<fn>
  package:front_end/src/base/performance_logger.dart 52:21           PerformanceLog.runAsync
  ===== asynchronous gap ===========================
  dart:async/zone.dart 1045                                          _CustomZone.registerCallback
  dart:async/zone.dart 962                                           _CustomZone.bindCallbackGuarded
  dart:async/schedule_microtask.dart 147                             scheduleMicrotask
  dart:async/future.dart 198                                         new Future.microtask
  package:front_end/src/base/performance_logger.dart 47:58           PerformanceLog.runAsync
  package:analyzer/src/dart/analysis/driver.dart 1183:20             AnalysisDriver._computeAnalysisResult
  ===== asynchronous gap ===========================
  dart:async/zone.dart 1045                                          _CustomZone.registerCallback
  dart:async/zone.dart 962                                           _CustomZone.bindCallbackGuarded
  dart:async/schedule_microtask.dart 147                             scheduleMicrotask
  dart:async/future.dart 198                                         new Future.microtask
  package:analyzer/src/dart/analysis/driver.dart 1147:47             AnalysisDriver._computeAnalysisResult
  package:analyzer/src/dart/analysis/driver.dart 879:19              AnalysisDriver.performWork
  ===== asynchronous gap ===========================
  dart:async/zone.dart 1045                                          _CustomZone.registerCallback
  dart:async/zone.dart 962                                           _CustomZone.bindCallbackGuarded
  dart:async/schedule_microtask.dart 147                             scheduleMicrotask
  dart:async/future.dart 198                                         new Future.microtask
  package:analyzer/src/dart/analysis/driver.dart 869:36              AnalysisDriver.performWork
  package:analyzer/src/dart/analysis/driver.dart 1887:24             AnalysisDriverScheduler._run
  ===== asynchronous gap ===========================
  dart:async/zone.dart 1053                                          _CustomZone.registerUnaryCallback
  dart:async-patch/dart:async/async_patch.dart 40                    _asyncThenWrapperHelper
  package:analyzer/src/dart/analysis/driver.dart 1845:29             AnalysisDriverScheduler._run
  package:analyzer/src/dart/analysis/driver.dart 1830:5              AnalysisDriverScheduler.start
  test/generated/resolver_test_case.dart 707:17                      ResolverTestCase.resetWith
  test/generated/resolver_test_case.dart 656:5                       ResolverTestCase.reset
  test/generated/resolver_test_case.dart 809:5                       ResolverTestCase.setUp
  dart:mirrors-patch/dart:mirrors/mirrors_impl.dart 531              _LocalInstanceMirror._invoke
  dart:mirrors-patch/dart:mirrors/mirrors_impl.dart 527              _LocalInstanceMirror.invoke
  dart:mirrors-patch/dart:mirrors/mirrors_impl.dart 555              _LocalClosureMirror.apply
  package:test_reflective_loader/test_reflective_loader.dart 215:32  _invokeSymbolIfExists
  package:test_reflective_loader/test_reflective_loader.dart 242:10  _runTest
  package:test_reflective_loader/test_reflective_loader.dart 126:18  defineReflectiveTests.<fn>.<fn>
  package:test/src/backend/declarer.dart 139:19                      Declarer.test.<fn>.<fn>
  ===== asynchronous gap ===========================
  dart:async/zone.dart 1053                                          _CustomZone.registerUnaryCallback
  dart:async-patch/dart:async/async_patch.dart 40                    _asyncThenWrapperHelper
  package:test/src/backend/declarer.dart 137:66                      Declarer.test.<fn>.<fn>
  package:test/src/backend/invoker.dart 206:15                       Invoker.waitForOutstandingCallbacks.<fn>
  ===== asynchronous gap ===========================
  dart:async/zone.dart 1045                                          _CustomZone.registerCallback
  dart:async/zone.dart 962                                           _CustomZone.bindCallbackGuarded
  dart:async/schedule_microtask.dart 147                             scheduleMicrotask
  dart:async/future.dart 198                                         new Future.microtask
  package:test/src/backend/invoker.dart 203:23                       Invoker.waitForOutstandingCallbacks.<fn>
  dart:async/zone.dart 1124                                          _rootRun
  dart:async/zone.dart 1021                                          _CustomZone.run
  dart:async/zone.dart 1499                                          runZoned
  package:test/src/backend/invoker.dart 203:5                        Invoker.waitForOutstandingCallbacks
  package:test/src/backend/declarer.dart 137:29                      Declarer.test.<fn>
  ===== asynchronous gap ===========================
  dart:async/zone.dart 1045                                          _CustomZone.registerCallback
  dart:async/zone.dart 962                                           _CustomZone.bindCallbackGuarded
  dart:async/schedule_microtask.dart 147                             scheduleMicrotask
  dart:async/future.dart 198                                         new Future.microtask
  package:test/src/backend/declarer.dart 122:66                      Declarer.test.<fn>
  package:test/src/backend/invoker.dart 351:23                       Invoker._onRun.<fn>.<fn>.<fn>
  ===== asynchronous gap ===========================
  dart:async/zone.dart 1045                                          _CustomZone.registerCallback
  dart:async/zone.dart 962                                           _CustomZone.bindCallbackGuarded
  dart:async/schedule_microtask.dart 147                             scheduleMicrotask
  dart:async/future.dart 198                                         new Future.microtask
  package:test/src/backend/invoker.dart 350:29                       Invoker._onRun.<fn>.<fn>.<fn>
  dart:async/future.dart 174                                         new Future.<fn>
  package:stack_trace/src/stack_zone_specification.dart 189:15       StackZoneSpecification._run
  package:stack_trace/src/stack_zone_specification.dart 99:48        StackZoneSpecification._registerCallback.<fn>
  dart:async/zone.dart 1120                                          _rootRun
  dart:async/zone.dart 1021                                          _CustomZone.run
  dart:async/zone.dart 923                                           _CustomZone.runGuarded
  dart:async/zone.dart 963                                           _CustomZone.bindCallbackGuarded.<fn>
  package:stack_trace/src/stack_zone_specification.dart 189:15       StackZoneSpecification._run
  package:stack_trace/src/stack_zone_specification.dart 99:48        StackZoneSpecification._registerCallback.<fn>
  dart:async/zone.dart 1124                                          _rootRun
  dart:async/zone.dart 1021                                          _CustomZone.run
  dart:async/zone.dart 947                                           _CustomZone.bindCallback.<fn>
  dart:async-patch/dart:async/timer_patch.dart 21                    Timer._createTimer.<fn>
  dart:isolate-patch/dart:isolate/timer_impl.dart 367                _Timer._runTimers
  dart:isolate-patch/dart:isolate/timer_impl.dart 401                _Timer._handleMessage
  dart:isolate-patch/dart:isolate/isolate_patch.dart 163             _RawReceivePortImpl._handleMessage
  ===== asynchronous gap ===========================
  dart:async/zone.dart 1045                                          _CustomZone.registerCallback
  dart:async/zone.dart 962                                           _CustomZone.bindCallbackGuarded
  dart:async/timer.dart 52                                           new Timer
  dart:async/timer.dart 87                                           Timer.run
  dart:async/future.dart 172                                         new Future
  package:test/src/backend/invoker.dart 350:13                       Invoker._onRun.<fn>.<fn>
  ===== asynchronous gap ===========================
  dart:async/zone.dart 1045                                          _CustomZone.registerCallback
  dart:async/zone.dart 962                                           _CustomZone.bindCallbackGuarded
  dart:async/schedule_microtask.dart 147                             scheduleMicrotask
  dart:async/future.dart 198                                         new Future.microtask
  package:test/src/backend/invoker.dart 337:25                       Invoker._onRun.<fn>.<fn>
  dart:async/zone.dart 1124                                          _rootRun
  dart:async/zone.dart 1021                                          _CustomZone.run
  dart:async/zone.dart 1499                                          runZoned
  package:test/src/backend/invoker.dart 337:7                        Invoker._onRun.<fn>
  package:stack_trace/src/chain.dart 93:24                           Chain.capture.<fn>
  dart:async/zone.dart 1124                                          _rootRun
  dart:async/zone.dart 1021                                          _CustomZone.run
  dart:async/zone.dart 1499                                          runZoned
  package:stack_trace/src/chain.dart 91:12                           Chain.capture
  package:test/src/backend/invoker.dart 336:11                       Invoker._onRun
  package:test/src/backend/live_test_controller.dart 188:11          LiveTestController._run
  package:test/src/backend/live_test_controller.dart 40:31           _LiveTest.run
  dart:async/future.dart 200                                         new Future.microtask.<fn>
  dart:async/schedule_microtask.dart 41                              _microtaskLoop
  dart:async/schedule_microtask.dart 50                              _startMicrotaskLoop
  dart:isolate-patch/dart:isolate/timer_impl.dart 376                _Timer._runTimers
  dart:isolate-patch/dart:isolate/timer_impl.dart 401                _Timer._handleMessage
  dart:isolate-patch/dart:isolate/isolate_patch.dart 163             _RawReceivePortImpl._handleMessage
@a-siva a-siva added area-kernel area-front-end Use area-front-end for front end / CFE / kernel format related issues. labels Jan 9, 2018
@eernstg
Copy link
Member

eernstg commented Jan 10, 2018

I understand that this issue reports on the stack overflow, but it might be worth noting that the given declaration of A is a compile-time error in strong mode and Dart 2 (and so are class A<T extends A<A>>{} and class A<T extends A>{}). In strong mode it's because a type in the bound of a formal type parameter cannot be raw (type arguments cannot be omitted), and even with the upcoming rules (see 'instantiate-to-bound.md' in this CL) a raw A cannot be a bound or in a bound, because it's not "simple" enough.

I'm commenting here because I can't see any indication (like //# 01: compile-time error) that the expected test outcome is an error, and I thought this might create some confusion if it's expected to compile cleanly.

@jensjoha
Copy link
Contributor

abstract class A<T extends A>{}

does the same thing in (strong mode):

$ pkg/front_end/tool/fasta compile tmp.dart --dump-ir --strong
Note: strong mode support is preliminary and may not work.
Unhandled exception:
Stack Overflow
#0      new _FixedSizeArrayIterator (dart:core-patch/dart:core/array.dart:203)
#1      List.iterator (dart:core-patch/dart:core/array.dart:84)
#2      KernelClassBuilder.buildTypeArguments (package:front_end/src/fasta/kernel/kernel_class_builder.dart:110:39)
#3      KernelNamedTypeBuilder.build (package:front_end/src/fasta/kernel/kernel_named_type_builder.dart:81:1)
#4      KernelClassBuilder.buildTypeArguments (package:front_end/src/fasta/kernel/kernel_class_builder.dart:111:31)
#5      KernelNamedTypeBuilder.build (package:front_end/src/fasta/kernel/kernel_named_type_builder.dart:81:1)
#6      KernelClassBuilder.buildTypeArguments (package:front_end/src/fasta/kernel/kernel_class_builder.dart:111:31)
#7      KernelNamedTypeBuilder.build (package:front_end/src/fasta/kernel/kernel_named_type_builder.dart:81:1)
#8      KernelClassBuilder.buildTypeArguments (package:front_end/src/fasta/kernel/kernel_class_builder.dart:111:31)
#9      KernelNamedTypeBuilder.build (package:front_end/src/fasta/kernel/kernel_named_type_builder.dart:81:1)
#10     KernelClassBuilder.buildTypeArguments (package:front_end/src/fasta/kernel/kernel_class_builder.dart:111:31)
#11     KernelNamedTypeBuilder.build (package:front_end/src/fasta/kernel/kernel_named_type_builder.dart:81:1)
#12     KernelClassBuilder.buildTypeArguments (package:front_end/src/fasta/kernel/kernel_class_builder.dart:111:31)
#13     KernelNamedTypeBuilder.build (package:front_end/src/fasta/kernel/kernel_named_type_builder.dart:81:1)
...
...
#12178  _Future._completeWithValue (dart:async/future_impl.dart:477)
#12179  _Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:507)
#12180  _rootRun (dart:async/zone.dart:1126)
#12181  _CustomZone.run (dart:async/zone.dart:1023)
#12182  _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:949)
#12183  _microtaskLoop (dart:async/schedule_microtask.dart:41)
#12184  _startMicrotaskLoop (dart:async/schedule_microtask.dart:50)
#12185  _runPendingImmediateCallback (dart:isolate-patch/dart:isolate/isolate_patch.dart:111)
#12186  _RawReceivePortImpl._handleMessage (dart:isolate-patch/dart:isolate/isolate_patch.dart:164)

@jensjoha jensjoha added the P1 A high priority bug; for example, a single project is unusable or has many test failures label Jan 10, 2018
@jensjoha jensjoha added this to Triaged in Dart Front End Jan 10, 2018
@MichaelRFairhurst
Copy link
Contributor Author

Regarding why the test doesn't assert an error, it technically was a spec mode test, asserting the lack of an error for pre-strong semantics. Its lucky that I didn't know that at the time when I reenabled it, so I turned it on for kernel by error and got this crash.

@eernstg
Copy link
Member

eernstg commented Jan 10, 2018

That is so cool! Who'd even want a simpler world to live in? ;-)

@askeksa-google askeksa-google added P2 A bug or feature request we're likely to work on crash Process exits with SIGSEGV, SIGABRT, etc. An unhandled exception is not a crash. and removed P1 A high priority bug; for example, a single project is unusable or has many test failures labels Jan 15, 2018
@jensjoha
Copy link
Contributor

jensjoha commented Feb 28, 2018

language_2/regress_23089_test crashes the same way.
Also

language_2/cyclic_typedef_test/10
language_2/cyclic_typedef_test/11

/cc @mraleph

@askeksa-google askeksa-google self-assigned this May 30, 2018
@askeksa-google askeksa-google moved this from Triaged to In Progress in Dart Front End May 30, 2018
dart-bot pushed a commit that referenced this issue Jun 22, 2018
Fixes #33208, #31810, #32416, #32417

Bug: http://dartbug.com/33208
Bug: http://dartbug.com/31810
Bug: http://dartbug.com/32416
Bug: http://dartbug.com/32417
Change-Id: Id178daf35be459fdefe04091bf929b5743d89e81
Reviewed-on: https://dart-review.googlesource.com/41264
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
@chloestefantsova
Copy link
Contributor

I believe this one is fixed as of 4fe71ec.

@kmillikin kmillikin moved this from In Progress to Done in Dart Front End Aug 1, 2018
@kmillikin kmillikin added area-front-end Use area-front-end for front end / CFE / kernel format related issues. front-end-kernel and removed area-front-end Use area-front-end for front end / CFE / kernel format related issues. labels Sep 19, 2018
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. crash Process exits with SIGSEGV, SIGABRT, etc. An unhandled exception is not a crash. front-end-kernel P2 A bug or feature request we're likely to work on
Projects
Development

No branches or pull requests

7 participants