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

Front end: Crash during inference. #37381

Closed
eernstg opened this issue Jun 27, 2019 · 2 comments
Closed

Front end: Crash during inference. #37381

eernstg opened this issue Jun 27, 2019 · 2 comments
Assignees
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@eernstg
Copy link
Member

eernstg commented Jun 27, 2019

Consider the following program:

class A<X> {
  R f<R>(R Function<X>(A<X>) f) => f<X>(this);
}

main() {
  A<num> a = A<int>();
  a.f(<X>(_) => 42);
}

Compilation of this program crashes, and the crash depends on R (change the signature of f to f(Function<X>(A<X>) f) and there is no crash).

With the dart from c4af35c, the response starts as follows:

Crash when compiling file:///usr/local/google/home/eernst/lang/dart/scratch/201906/n007.dart,
at character offset 68:
NoSuchMethodError: The method 'accept' was called on null.
Receiver: null
Tried calling: accept(Instance of '_TypeSchemaEliminationVisitor')
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:50:5)
#1      _TypeSchemaEliminationVisitor.run (package:front_end/src/fasta/type_inference/type_schema_elimination.dart:126:25)
#2      greatestClosure (package:front_end/src/fasta/type_inference/type_schema_elimination.dart:26:35)
#3      new ClosureContext (package:front_end/src/fasta/type_inference/type_inferrer.dart:215:9)
#4      TypeInferrerImpl.inferLocalFunction (package:front_end/src/fasta/type_inference/type_inferrer.dart:1455:41)
#5      InferenceVisitor.visitFunctionNodeJudgment (package:front_end/src/fasta/kernel/inference_visitor.dart:449:21)
#6      InferenceVisitor.visitFunctionExpression (package:front_end/src/fasta/kernel/inference_visitor.dart:464:27)
...

Similarly, dart2js from c4af35c responds as follows:

n007.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: Crash when compiling file:///usr/local/google/home/eernst/lang/dart/scratch/201906/n007.dart,
at character offset 68:
'package:front_end/src/fasta/type_inference/type_inferrer.dart': Failed assertion: line 213 pos 12: 'returnContext != null': is not true.
#0      _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:40:39)
#1      _AssertionError._throwNew (dart:core-patch/errors_patch.dart:36:5)
#2      new ClosureContext (package:front_end/src/fasta/type_inference/type_inferrer.dart:213:12)
#3      TypeInferrerImpl.inferLocalFunction (package:front_end/src/fasta/type_inference/type_inferrer.dart:1455:41)
#4      InferenceVisitor.visitFunctionNodeJudgment (package:front_end/src/fasta/kernel/inference_visitor.dart:449:21)
#5      InferenceVisitor.visitFunctionExpression (package:front_end/src/fasta/kernel/inference_visitor.dart:464:27)

I've labeled this crash as a front end issue because of the call sites, and because the problem seems to be shared by several tools (even though the error reports are not identical, they are quite similar).

Note the related issue #37382.

@eernstg eernstg added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) area-front-end Use area-front-end for front end / CFE / kernel format related issues. labels Jun 27, 2019
@mraleph
Copy link
Member

mraleph commented Jun 27, 2019

Dima, could you check this one out?

@chloestefantsova
Copy link
Contributor

It's a nice somewhat fractal test case!

Proposed fix is here: https://dart-review.googlesource.com/c/sdk/+/107505.

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. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

3 participants