Quantcast
Channel: Node.js Tools for Visual Studio
Viewing all articles
Browse latest Browse all 4630

Edited Issue: Deadlock loading an NTVS project [577]

$
0
0
I just hit this with recent bits. The issue is with lock contention in NodeModulesNode. Specifically, NodeModulesNode.ReloadHierarchy() and NodeModulesNode.ReloadModules()
both lock _lock, and NodeModulesNode.ReloadModules() may lock _lock on a background thread and while holding _lock, indirectly, synchronously call NodeModulesNode.ReloadHierarchy() on the main thread, causing the deadlock. Consider the following background thread callstack:

> Microsoft.NodejsTools.dll!Microsoft.NodejsTools.Project.NodejsProjectNodeProperties.NodeExePath.get() Line 59 C#
Microsoft.NodejsTools.dll!Microsoft.NodejsTools.Project.NodeModulesNode.GetNpmPathFromNodePathInProject() Line 117 C#
Microsoft.NodejsTools.dll!Microsoft.NodejsTools.Project.NodeModulesNode.NpmPathProvider.PathToNpm.get() Line 134 C#
Microsoft.NodejsTools.Npm.dll!Microsoft.NodejsTools.Npm.SPI.NpmController.PathToNpm.get() Line 53 C#
Microsoft.NodejsTools.Npm.dll!Microsoft.NodejsTools.Npm.SPI.NpmController.Refresh() Line 86 C#
Microsoft.NodejsTools.dll!Microsoft.NodejsTools.Project.NodeModulesNode.ReloadModules() Line 212 C#
Microsoft.NodejsTools.dll!Microsoft.NodejsTools.Project.NodeModulesNode.UpdateModulesFromTimer() Line 199 C#
Microsoft.NodejsTools.dll!Microsoft.NodejsTools.Project.NodeModulesNode.RestartFileSystemWatcherTimer.AnonymousMethod__4(object o) Line 171 C#
mscorlib.dll!System.Threading.TimerQueueTimer.CallCallbackInContext(object state) Line 723 C#
mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 581 C#
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Line 531 C#
mscorlib.dll!System.Threading.TimerQueueTimer.CallCallback() Line 706 C#
mscorlib.dll!System.Threading.TimerQueueTimer.Fire() Line 666 C#
mscorlib.dll!System.Threading.TimerQueue.FireNextTimers() Line 424 C#
mscorlib.dll!System.Threading.TimerQueue.AppDomainTimerCallback() Line 207 C#


It appears that a simple fix is to remove the locking around access to _npmController, as it seems to only ever get dereferenced on the main thread.



Viewing all articles
Browse latest Browse all 4630

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>