Skip to content

#582 VS 2013 Crash NullReferenceException#595

Merged
mousetraps merged 1 commit intomicrosoft:masterfrom
mousetraps:i582
Nov 17, 2015
Merged

#582 VS 2013 Crash NullReferenceException#595
mousetraps merged 1 commit intomicrosoft:masterfrom
mousetraps:i582

Conversation

@mousetraps
Copy link
Copy Markdown
Contributor

  • it was sometimes possible for one of the children in moduleTree to be
    null. Check for null before mod.Name string comparison.

fix #582

- it was sometimes possible for one of the children in moduleTree to be
  null. Check for null before mod.Name string comparison.
@mousetraps
Copy link
Copy Markdown
Contributor Author

I couldn't actually reproduce this issue, but as described in #582 (comment), this is the only way that a NRE could be thrown with the provided call stack.

Still haven't conclusively narrowed down how the tree could be null, but I believe it may be happening here:
https://github.com/Microsoft/nodejstools/blob/master/Nodejs/Product/Analysis/Analysis/ProjectEntry.cs#L106

@mousetraps
Copy link
Copy Markdown
Contributor Author

@DinoV Any chance you could review this? It's not entirely clear to me in what scenarios mod might be null here

@billti
Copy link
Copy Markdown
Member

billti commented Nov 16, 2015

This was the same defensive code I was considering adding, but still couldn't figure out why this would ever occur :-/

Barring any deeper understanding of what is causing this, looks like the right change to make to me 👍

mousetraps added a commit that referenced this pull request Nov 17, 2015
#582 VS 2013 Crash NullReferenceException
@mousetraps mousetraps merged commit 80a26ae into microsoft:master Nov 17, 2015
@DinoV
Copy link
Copy Markdown
Contributor

DinoV commented Nov 30, 2015

I suspect it is actually a race condition, especially given that it's reported to be intermittent. ModuleTree.Children is a non-thread safe dictionary, and AddChildVisibilitiesExcludingNodeModules is accessing it w/o holding the ModuleTable lock. _table.RequireModule will acquire the lock, do the lookup, and release it. Then we access the children in a non-thread safe manner, so we can come back with a corrupted dictionary that has null values (or get other strange behavior).

It probably makes sense to have a ModuleTable.GetChildrenExcludingNodeModules which does the RequireModule + GetChildrenExcludingNodeModules with the lock held the entire time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

4 participants