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

Analyzer null pointer crash when combining --strong and --warnings #26466

Closed
leafpetersen opened this issue May 16, 2016 · 4 comments
Closed
Assignees
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion.

Comments

@leafpetersen
Copy link
Member

Analyzing a trivial file that just imports dart:html with current dev release (1.17-dev.3.0) or bleeding edge analyzer passing flags --strong --warnings, produces the following crash:

Unhandled exception:
The null object does not have a method '_setErrorState'.

NoSuchMethodError: method not found: '_setErrorState'
Receiver: null
Arguments: [Instance of 'ListResultDescriptorImpl<VariableElement>', Instance of 'CaughtException']
#0      Object._noSuchMethod (dart:core-patch/object_patch.dart:42)
#1      Object.noSuchMethod (dart:core-patch/object_patch.dart:45)
#2      CacheEntry._setErrorState.<anonymous closure> (package:analyzer/src/context/cache.dart:675)
#3      _HashFieldBase&_HashBase&_OperatorEqualsAndHashCode&SetMixin.forEach (dart:collection/set.dart:145)
#4      CacheEntry._setErrorState (package:analyzer/src/context/cache.dart:673)
#5      CacheEntry.setErrorState (package:analyzer/src/context/cache.dart:460)
#6      AnalysisDriver.performWorkItem (package:analyzer/src/task/driver.dart:270)
#7      AnalysisDriver.computeResult (package:analyzer/src/task/driver.dart:109)
#8      AnalysisContextImpl.computeResult (package:analyzer/src/context/context.dart:667)
#9      AnalysisContextImpl.computeErrors (package:analyzer/src/context/context.dart:615)
#10     AnalyzerImpl.prepareErrors.<anonymous closure> (package:analyzer_cli/src/analyzer_impl.dart:127)
#11     _PerformanceTagImpl.makeCurrentWhile (package:analyzer/src/generated/utilities_general.dart:212)
#12     AnalyzerImpl.prepareErrors (package:analyzer_cli/src/analyzer_impl.dart:125)
#13     AnalyzerImpl._analyzeSync (package:analyzer_cli/src/analyzer_impl.dart:161)
#14     AnalyzerImpl.analyzeSync (package:analyzer_cli/src/analyzer_impl.dart:120)
#15     Driver._runAnalyzer (package:analyzer_cli/src/driver.dart:575)
#16     Driver._analyzeAllImpl (package:analyzer_cli/src/driver.dart:213)
#17     Driver._analyzeAll.<anonymous closure> (package:analyzer_cli/src/driver.dart:156)
#18     _PerformanceTagImpl.makeCurrentWhile (package:analyzer/src/generated/utilities_general.dart:212)
#19     Driver._analyzeAll (package:analyzer_cli/src/driver.dart:155)
#20     Driver.start (package:analyzer_cli/src/driver.dart:136)
#21     main (file:///b/build/slave/dart-sdk-mac-dev/build/sdk/pkg/analyzer_cli/bin/analyzer.dart:11)
#22     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:259)
#23     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:148)

Code is:

import 'dart:html';
@leafpetersen leafpetersen added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. analyzer-strong-mode labels May 16, 2016
@bwilkerson bwilkerson self-assigned this May 17, 2016
@bwilkerson
Copy link
Member

I think there are two problems here.

The first problem is that we're throwing an exception while trying to resolve html_dartium.dart:

Mismatch in DeclarationResolver while resolving .../dart-sdk/lib/html/dartium/html_dartium.dart
Could not find element with name "_window" at 2125
Path to root: DeclaredSimpleIdentifier, VariableDeclarationImpl, VariableDeclarationListImpl, TopLevelVariableDeclarationImpl, CompilationUnitImpl

#0 RecursiveAstVisitor&ExistingElementResolver._mismatch (package:analyzer/src/generated/resolver.dart:3457:5)
#1 DeclarationResolver._findWithNameAndOffset (package:analyzer/src/generated/resolver.dart:2725:5)
#2 DeclarationResolver._findIdentifier (package:analyzer/src/generated/resolver.dart:2683:23)
#3 DeclarationResolver.visitVariableDeclaration (package:analyzer/src/generated/resolver.dart:2638:17)
#4 VariableDeclarationImpl.accept (package:analyzer/src/dart/ast/ast.dart:10679:15)
#5 NodeListImpl.accept (package:analyzer/src/dart/ast/ast.dart:7682:20)
#6 VariableDeclarationListImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:10777:16)
#7 RecursiveAstVisitor.visitVariableDeclarationList (package:analyzer/dart/ast/visitor.dart:1960:10)
#8 DeclarationResolver.visitVariableDeclarationList (package:analyzer/src/generated/resolver.dart:2655:39)
#9 VariableDeclarationListImpl.accept (package:analyzer/src/dart/ast/ast.dart:10771:15)
#10 TopLevelVariableDeclarationImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:9991:20)
#11 RecursiveAstVisitor.visitTopLevelVariableDeclaration (package:analyzer/dart/ast/visitor.dart:1918:10)
#12 DeclarationResolver.visitTopLevelVariableDeclaration (package:analyzer/src/generated/resolver.dart:2590:43)
#13 TopLevelVariableDeclarationImpl.accept (package:analyzer/src/dart/ast/ast.dart:9986:15)
#14 NodeListImpl.accept (package:analyzer/src/dart/ast/ast.dart:7682:20)
#15 CompilationUnitImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:2440:21)
#16 RecursiveAstVisitor.visitCompilationUnit (package:analyzer/dart/ast/visitor.dart:1449:10)
#17 CompilationUnitImpl.accept (package:analyzer/src/dart/ast/ast.dart:2433:15)
#18 DeclarationResolver.resolve (package:analyzer/src/generated/resolver.dart:2222:10)
#19 BuildCompilationUnitElementTask.internalPerform (package:analyzer/src/task/dart.dart:1017:33)
#20 AnalysisTask._safelyPerform (package:analyzer/task/model.dart:329:9)
#21 AnalysisTask.perform (package:analyzer/task/model.dart:229:7)
#22 AnalysisDriver.performWorkItem (package:analyzer/src/task/driver.dart:276:10)
#23 AnalysisDriver.computeResult (package:analyzer/src/task/driver.dart:109:18)
#24 AnalysisContextImpl.computeResult (package:analyzer/src/context/context.dart:667:14)
#25 AnalysisContextImpl.computeErrors (package:analyzer/src/context/context.dart:615:12)
#26 AnalyzerImpl.prepareErrors. (package:analyzer_cli/src/analyzer_impl.dart:127:17)
#27 _PerformanceTagImpl.makeCurrentWhile (package:analyzer/src/generated/utilities_general.dart:212:15)
#28 AnalyzerImpl.prepareErrors (package:analyzer_cli/src/analyzer_impl.dart:125:30)
#29 AnalyzerImpl._analyzeSync (package:analyzer_cli/src/analyzer_impl.dart:161:5)
#30 AnalyzerImpl.analyzeSync (package:analyzer_cli/src/analyzer_impl.dart:120:12)
#31 Driver._runAnalyzer (package:analyzer_cli/src/driver.dart:603:34)
#32 Driver._analyzeAllImpl (package:analyzer_cli/src/driver.dart:215:30)
#33 Driver._analyzeAll. (package:analyzer_cli/src/driver.dart:158:14)
#34 _PerformanceTagImpl.makeCurrentWhile (package:analyzer/src/generated/utilities_general.dart:212:15)
#35 Driver._analyzeAll (package:analyzer_cli/src/driver.dart:157:27)
#36 Driver.start (package:analyzer_cli/src/driver.dart:138:32)
#37 main (file:///Users/brianwilkerson/src/dart/sdk/sdk/pkg/analyzer_cli/bin/analyzer.dart:11:11)
#38 _startIsolate. (dart:isolate-patch/isolate_patch.dart:259)
#39 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:148)

This looks like it could be caused by a difference between the summaries and the file we're trying to resolve. The file defined a top-level variable named _window, while the element model we're trying to match it to defines a top-level variable named window.

@scheglov Could you look into the first problem?

The second problem is that dependencies can cross partition boundaries, but we didn't take that possibility into account. I'll look at how to fix that problem.

@scheglov
Copy link
Contributor

scheglov added a commit that referenced this issue May 17, 2016
This would correspond to the code in build_sdk_summaries.dart, which
creates strong mode summaries.

R=brianwilkerson@google.com, paulberry@google.com
BUG= #26466

Review URL: https://codereview.chromium.org/1988853002 .
@scheglov
Copy link
Contributor

Additional fix https://codereview.chromium.org/2003863002

scheglov added a commit that referenced this issue May 22, 2016
Eventually we might want to go over all of the code and sprinkle it
with checks like with to avoid re-resolving what we already know, and
to avoid updating parts of element model which cannot be updated
because the element model is resynthesized from a summary.

R=brianwilkerson@google.com
BUG= #26466

Review URL: https://codereview.chromium.org/2003863002 .
@bwilkerson
Copy link
Member

This should solve the underlying problem: https://codereview.chromium.org/2008133002/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion.
Projects
None yet
Development

No branches or pull requests

3 participants