Open heejaechang opened 5 years ago
cc @mavasani
This appears to be a threading issue: http://source.roslyn.io/#Microsoft.CodeAnalysis.CSharp/Operations/CSharpOperationFactory_Methods.cs,61. Multiple threads could be attempting to get the arguments of an invocation at the same time, and one of these threads could hit the cache if the timing is correct. The operation returned from the cache already has a parent operation, a different ArgumentOperation, so the debug assert is hit. Most of the time, we should end up in an OK state afterwards because the Interlocked.CompareExchange when creating the arguments will not set the new arguments, as arguments were already set, but there is a chance that we could end up with split trees if the thread timing is just right. The solution is to ensure that any non-lazy operation creation does not hit the cache in the factories.
The assert that was revealing this race is being disabled for now in https://github.com/dotnet/roslyn/pull/39018, to allow tests to pass. Our plan for fixing the race is to make IOperation non-lazy, which will have some additional benefits:
repro step. first clone this repo - https://github.com/nopSolutions/nopCommerce and enable full solution analysis in debug VS (assert is debug only assert)
....
another repro step. with Roslyn, enable VB full solution analysis, and open src\EditorFeatures\VisualBasicTest\CodeActions\MoveType\BasicMoveTypeTestsBase.vb with debug Roslyn bit.