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

CFE crashes when invoking some extension method getters as functions. #40713

Closed
jacob314 opened this issue Feb 20, 2020 · 1 comment
Closed
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

@jacob314
Copy link
Member

jacob314 commented Feb 20, 2020

The Common Front End (CFE) and kernel crashes when given code that attempts to call an extension method getter like a function.

Repro:

extension SafeAccess<T> on Iterable<T> {
  T get safeFirst {
    return isNotEmpty ? first : null;
  }
}

void main() {
      test('safeFirst', () {
        final list = []; // The key to the repro is to use a list<dynamic>
        expect(list.safeFirst(), isNull);
      });
}
`

Exception triggered:

Crash when compiling file:///usr/local/google/home/jacobr/git/devtools/packages/devtools_app/test/utils_test.dart,
at character offset 278:
Bad state: No element
#0 List.first (dart:core-patch/array.dart:205:5)
#1 TypeInferrerImpl._inferGenericExtensionMethodInvocation
(package:front_end/src/fasta/type_inference/type_inferrer.dart:2101:42)
#2 TypeInferrerImpl.inferInvocation (package:front_end/src/fasta/type_inference/type_inferrer.dart:2063:14)
#3 TypeInferrerImpl._inferExtensionInvocation (package:front_end/src/fasta/type_inference/type_inferrer.dart:2775:40)
#4 TypeInferrerImpl.inferMethodInvocation (package:front_end/src/fasta/type_inference/type_inferrer.dart:3204:16)
#5 InferenceVisitor.visitMethodInvocation (package:front_end/src/fasta/kernel/inference_visitor.dart:2312:21)
#6 MethodInvocation.accept1 (package:kernel/ast.dart:3469:9)
#7 TypeInferrerImpl.inferExpression (package:front_end/src/fasta/type_inference/type_inferrer.dart:1992:27)
#8 TypeInferrerImpl._inferInvocation (package:front_end/src/fasta/type_inference/type_inferrer.dart:2249:44)
#9 TypeInferrerImpl.inferInvocation (package:front_end/src/fasta/type_inference/type_inferrer.dart:2077:12)
#10 InferenceVisitor.visitStaticInvocation (package:front_end/src/fasta/kernel/inference_visitor.dart:5018:49)
#11 StaticInvocation.accept1 (package:kernel/ast.dart:3581:9)
#12 TypeInferrerImpl.inferExpression (package:front_end/src/fasta/type_inference/type_inferrer.dart:1992:27)
#13 InferenceVisitor.visitExpressionStatement (package:front_end/src/fasta/kernel/inference_visitor.dart:703:49)
#14 ExpressionStatement.accept (package:kernel/ast.dart:4730:43)
#15 TypeInferrerImpl.inferStatement (package:front_end/src/fasta/type_inference/type_inferrer.dart:3381:24)
#16 InferenceVisitor._visitStatements (package:front_end/src/fasta/kernel/inference_visitor.dart:299:20)
#17 InferenceVisitor.visitBlock (package:front_end/src/fasta/kernel/inference_visitor.dart:320:30)
#18 Block.accept (package:kernel/ast.dart:4758:43)
#19 TypeInferrerImpl.inferStatement (package:front_end/src/fasta/type_inference/type_inferrer.dart:3381:24)
#20 TypeInferrerImpl.inferLocalFunction (package:front_end/src/fasta/type_inference/type_inferrer.dart:2616:43)
#21 InferenceVisitor.visitFunctionNode (package:front_end/src/fasta/kernel/inference_visitor.dart:1041:21)
#22 InferenceVisitor.visitFunctionExpression (package:front_end/src/fasta/kernel/inference_visitor.dart:1065:9)
#23 FunctionExpression.accept1 (package:kernel/ast.dart:4559:9)
#24 TypeInferrerImpl.inferExpression (package:front_end/src/fasta/type_inference/type_inferrer.dart:1992:27)
#25 TypeInferrerImpl._inferInvocation (package:front_end/src/fasta/type_inference/type_inferrer.dart:2249:44)
#26 TypeInferrerImpl.inferInvocation (package:front_end/src/fasta/type_inference/type_inferrer.dart:2077:12)
#27 InferenceVisitor.visitStaticInvocation (package:front_end/src/fasta/kernel/inference_visitor.dart:5018:49)
#28 StaticInvocation.accept1 (package:kernel/ast.dart:3581:9)
#29 TypeInferrerImpl.inferExpression (package:front_end/src/fasta/type_inference/type_inferrer.dart:1992:27)
#30 InferenceVisitor.visitExpressionStatement (package:front_end/src/fasta/kernel/inference_visitor.dart:703:49)
#31 ExpressionStatement.accept (package:kernel/ast.dart:4730:43)
#32 TypeInferrerImpl.inferStatement (package:front_end/src/fasta/type_inference/type_inferrer.dart:3381:24)
#33 InferenceVisitor._visitStatements (package:front_end/src/fasta/kernel/inference_visitor.dart:299:20)
#34 InferenceVisitor.visitBlock (package:front_end/src/fasta/kernel/inference_visitor.dart:320:30)
#35 Block.accept (package:kernel/ast.dart:4758:43)
#36 TypeInferrerImpl.inferStatement (package:front_end/src/fasta/type_inference/type_inferrer.dart:3381:24)
#37 TypeInferrerImpl.inferLocalFunction (package:front_end/src/fasta/type_inference/type_inferrer.dart:2616:43)
#38 InferenceVisitor.visitFunctionNode (package:front_end/src/fasta/kernel/inference_visitor.dart:1041:21)
#39 InferenceVisitor.visitFunctionExpression (package:front_end/src/fasta/kernel/inference_visitor.dart:1065:9)
#40 FunctionExpression.accept1 (package:kernel/ast.dart:4559:9)
#41 TypeInferrerImpl.inferExpression (package:front_end/src/fasta/type_inference/type_inferrer.dart:1992:27)
#42 TypeInferrerImpl._inferInvocation (package:front_end/src/fasta/type_inference/type_inferrer.dart:2249:44)
#43 TypeInferrerImpl.inferInvocation (package:front_end/src/fasta/type_inference/type_inferrer.dart:2077:12)
#44 InferenceVisitor.visitStaticInvocation (package:front_end/src/fasta/kernel/inference_visitor.dart:5018:49)
#45 StaticInvocation.accept1 (package:kernel/ast.dart:3581:9)
#46 TypeInferrerImpl.inferExpression (package:front_end/src/fasta/type_inference/type_inferrer.dart:1992:27)
#47 InferenceVisitor.visitExpressionStatement (package:front_end/src/fasta/kernel/inference_visitor.dart:703:49)
#48 ExpressionStatement.accept (package:kernel/ast.dart:4730:43)
#49 TypeInferrerImpl.inferStatement (package:front_end/src/fasta/type_inference/type_inferrer.dart:3381:24)
#50 InferenceVisitor._visitStatements (package:front_end/src/fasta/kernel/inference_visitor.dart:299:20)
#51 InferenceVisitor.visitBlock (package:front_end/src/fasta/kernel/inference_visitor.dart:320:30)
#52 Block.accept (package:kernel/ast.dart:4758:43)
#53 TypeInferrerImpl.inferStatement (package:front_end/src/fasta/type_inference/type_inferrer.dart:3381:24)
#54 TypeInferrerImpl.inferLocalFunction (package:front_end/src/fasta/type_inference/type_inferrer.dart:2616:43)
#55 InferenceVisitor.visitFunctionNode (package:front_end/src/fasta/kernel/inference_visitor.dart:1041:21)
#56 InferenceVisitor.visitFunctionExpression (package:front_end/src/fasta/kernel/inference_visitor.dart:1065:9)
#57 FunctionExpression.accept1 (package:kernel/ast.dart:4559:9)
#58 TypeInferrerImpl.inferExpression (package:front_end/src/fasta/type_inference/type_inferrer.dart:1992:27)
#59 TypeInferrerImpl._inferInvocation (package:front_end/src/fasta/type_inference/type_inferrer.dart:2249:44)
#60 TypeInferrerImpl.inferInvocation (package:front_end/src/fasta/type_inference/type_inferrer.dart:2077:12)
#61 InferenceVisitor.visitStaticInvocation (package:front_end/src/fasta/kernel/inference_visitor.dart:5018:49)
#62 StaticInvocation.accept1 (package:kernel/ast.dart:3581:9)
#63 TypeInferrerImpl.inferExpression (package:front_end/src/fasta/type_inference/type_inferrer.dart:1992:27)
#64 InferenceVisitor.visitExpressionStatement (package:front_end/src/fasta/kernel/inference_visitor.dart:703:49)
#65 ExpressionStatement.accept (package:kernel/ast.dart:4730:43)
#66 TypeInferrerImpl.inferStatement (package:front_end/src/fasta/type_inference/type_inferrer.dart:3381:24)
#67 InferenceVisitor._visitStatements (package:front_end/src/fasta/kernel/inference_visitor.dart:299:20)
#68 InferenceVisitor.visitBlock (package:front_end/src/fasta/kernel/inference_visitor.dart:320:30)
#69 Block.accept (package:kernel/ast.dart:4758:43)
#70 TypeInferrerImpl.inferStatement (package:front_end/src/fasta/type_inference/type_inferrer.dart:3381:24)
#71 TypeInferrerImpl.inferFunctionBody (package:front_end/src/fasta/type_inference/type_inferrer.dart:2033:39)
#72 BodyBuilder.finishFunction (package:front_end/src/fasta/kernel/body_builder.dart:955:28)
#73 DietListener.listenerFinishFunction (package:front_end/src/fasta/source/diet_listener.dart:911:14)
#74 DietListener.buildFunctionBody (package:front_end/src/fasta/source/diet_listener.dart:949:7)
#75 DietListener.endTopLevelMethod (package:front_end/src/fasta/source/diet_listener.dart:353:5)
#76 Parser.parseTopLevelMethod (package:_fe_analyzer_shared/src/parser/parser_impl.dart:2523:14)
#77 Parser.parseTopLevelMemberImpl (package:_fe_analyzer_shared/src/parser/parser_impl.dart:2377:14)
#78 Parser.parseTopLevelDeclarationImpl (package:_fe_analyzer_shared/src/parser/parser_impl.dart:495:14)
#79 Parser.parseUnit (package:_fe_analyzer_shared/src/parser/parser_impl.dart:352:15)
#80 SourceLoader.buildBody (package:front_end/src/fasta/source/source_loader.dart:347:14)

#81 Loader.buildBodies (package:front_end/src/fasta/loader.dart:233:15)

#82 KernelTarget.buildComponent. (package:front_end/src/fasta/kernel/kernel_target.dart:340:20)
#83 withCrashReporting (package:front_end/src/fasta/crash.dart:122:24)
#84 KernelTarget.buildComponent (package:front_end/src/fasta/kernel/kernel_target.dart:338:12)
#85 IncrementalCompiler.computeDelta. (package:front_end/src/fasta/incremental_compiler.dart:238:28)

#86 IncrementalCompiler.computeDelta. (package:front_end/src/fasta/incremental_compiler.dart)
#87 CompilerContext.runInContext..
(package:front_end/src/fasta/compiler_context.dart:123:46)
#88 new Future.sync (dart:async/future.dart:224:31)
#89 CompilerContext.runInContext. (package:front_end/src/fasta/compiler_context.dart:123:19)
#90 _rootRun (dart:async/zone.dart:1126:13)
#91 _CustomZone.run (dart:async/zone.dart:1023:19)
#92 _runZoned (dart:async/zone.dart:1518:10)
#93 runZoned (dart:async/zone.dart:1465:12)
#94 CompilerContext.runInContext (package:front_end/src/fasta/compiler_context.dart:122:12)
#95 IncrementalCompiler.computeDelta (package:front_end/src/fasta/incremental_compiler.dart:175:20)
#96 IncrementalCompiler.compile (package:vm/incremental_compiler.dart:58:46)
#97 FrontendCompiler.compile. (package:frontend_server/frontend_server.dart:474:59)
#98 new Future. (dart:async/future.dart:176:37)
#99 _rootRun (dart:async/zone.dart:1122:38)
#100 _CustomZone.run (dart:async/zone.dart:1023:19)
#101 _CustomZone.runGuarded (dart:async/zone.dart:925:7)
#102 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:965:23)
#103 _rootRun (dart:async/zone.dart:1126:13)
#104 _CustomZone.run (dart:async/zone.dart:1023:19)
#105 _CustomZone.bindCallback. (dart:async/zone.dart:949:23)
#106 Timer._createTimer. (dart:async-patch/timer_patch.dart:23:15)
#107 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:398:19)
#108 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:429:5)
#109 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)

@jacob314 jacob314 added the type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) label Feb 20, 2020
@jacob314
Copy link
Member Author

see
flutter/devtools#1647
for more context on how the bug was triggered.

@mraleph mraleph added the area-front-end Use area-front-end for front end / CFE / kernel format related issues. label Feb 25, 2020
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

2 participants