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

VS 2013 Crash Null reference exception 10-22 build (intermittent) #582

Closed
rkavalap opened this issue Nov 4, 2015 · 2 comments · Fixed by #595
Closed

VS 2013 Crash Null reference exception 10-22 build (intermittent) #582

rkavalap opened this issue Nov 4, 2015 · 2 comments · Fixed by #595

Comments

@rkavalap
Copy link

rkavalap commented Nov 4, 2015

VS crashed on launching one of the nodejs projects. Below is the stack trace emitted on crash and event viewer trace.

VS 2013, NTVS 10-22 dev build.

Problem signature:
Problem Event Name: CLR20r3
Problem Signature 01: devenv.exe
Problem Signature 02: 12.0.40629.0
Problem Signature 03: 5590c8a4
Problem Signature 04: Microsoft.NodejsTools.Analysis
Problem Signature 05: 1.1.31022.2
Problem Signature 06: 562935dd
Problem Signature 07: ac5
Problem Signature 08: 0
Problem Signature 09: System.NullReferenceException
OS Version: 6.3.9600.2.0.0.256.4
Locale ID: 1033
Additional Information 1: 5861
Additional Information 2: 5861822e1919d7c014bbb064c64908b2
Additional Information 3: 1318
Additional Information 4: 13181ae637ac2592fac0ca2dd662cdcc

Application: devenv.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.NullReferenceException
Stack:
at Microsoft.NodejsTools.Analysis.ModuleTreeExtensions+<>c.b__0_0(Microsoft.NodejsTools.Analysis.ModuleTree)
at System.Linq.Enumerable+WhereArrayIterator`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].MoveNext()
at Microsoft.NodejsTools.Analysis.Analyzer.RequireAnalysisUnit.AddChildVisibilitiesExcludingNodeModules(Microsoft.NodejsTools.Analysis.ModuleTree)
at Microsoft.NodejsTools.Analysis.Analyzer.RequireAnalysisUnit.AddChildVisibilitiesExcludingNodeModules(Microsoft.NodejsTools.Analysis.ModuleTree)
at Microsoft.NodejsTools.Analysis.Analyzer.RequireAnalysisUnit.AnalyzeWorker(Microsoft.NodejsTools.Analysis.Analyzer.DDG, System.Threading.CancellationToken)
at Microsoft.NodejsTools.Analysis.JsAnalyzer+TreeUpdateAnalysis.Analyze(System.Threading.CancellationToken)
at Microsoft.NodejsTools.Intellisense.VsProjectAnalyzer+AnalysisQueue.Worker(System.Object)
at System.Threading.ThreadHelper.ThreadStart_Context(System.Object)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Threading.ThreadHelper.ThreadStart(System.Object)

@billti
Copy link
Member

billti commented Nov 5, 2015

I've been staring at this call stack and code ( https://github.com/Microsoft/nodejstools/blob/master/Nodejs/Product/Analysis/Analysis/ModuleTreeExtensions.cs#L23 ) for a while now, and for the life of me can't figure out how this could get a NullReferenceException.

Unless ModuleTree.Name could be null in the Where predicate, but then I'd expect the top of the stack to be in the enumerator. It doesn't look from the code like it's possible for ModuleTree.Children to be null, as it has an initializer in the class and is never reassigned to (thus .Values.ToArray() should always at least return an empty array).

@mousetraps Any ideas? Looks like you wrote this about 2 months ago, as well as some other module analysis changes.

@mousetraps
Copy link
Contributor

@billti The key thing here is that GetChildrenExcludingNodeModules isn't returning the values directly, but rather an enumerator, so no matter what, GetChildrenExcludingNodeModules returns the result successfully. Next, WhereArrayIterator'1.MoveNext() ends up getting called during the foreach in RequireAnalysisUnit.AddChildVisibilitiesExcludingNodeModules.

https://github.com/Microsoft/nodejstools/blob/8169f1e6fe7c83e3f4061631a44de79b3e80ec73/Nodejs/Product/Analysis/Analysis/Analyzer/RequireAnalysisUnit.cs#L42

Lastly, MoveNext triggers the predicate defined in Where in GetChildrenExcludingNodeModules to run, which explains the call stack.

The only way for an exception to be thrown here is if mod is null - mod.Name being null won't trigger a NRE in a string comparison.

Still don't know why ModuleTree is null here, though...

mousetraps added a commit to mousetraps/nodejstools that referenced this issue Nov 16, 2015
- it was sometimes possible for one of the children in moduleTree to be
  null. Check for null before mod.Name string comparison.
mousetraps added a commit that referenced this issue Nov 17, 2015
#582 VS 2013 Crash NullReferenceException
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants