-
Notifications
You must be signed in to change notification settings - Fork 789
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
fix for race condition in FileIndex.fileIndexOfFile #18008
Conversation
❗ Release notes required
|
Can somebody add the "No release notes" label? Thanks! |
Actually you can probably add them - it's a bug fix, it's notable from the product perspective :) (as opposed to refactoring or adding tests - they could be very useful but don't compose a new "release" really). |
That makes sense. I have added them. BTW the change is small, hopefully easy to review. |
Thanks for the contribution, Martin. The change is indeed small, but anything that touches critical parts of the compiler needs a focused review :) We're a bit busy with .NET9 handling and some internal stuff right now, we hope to get to the PRs soon - thanks for your patience! |
cb4d062
to
4bce3d3
Compare
Some remarks that might help in reviewing this PR:
|
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
ILVerify succeeds locally for this same commit |
I think I have something similar happening in my PR, it's very annoying indeed. |
It is indeed failing in this branch locally for me:
> git diff
diff --git a/tests/ILVerify/ilverify_FSharp.Compiler.Service_Release_netstandard2.0.bsl b/tests/ILVerify/ilverify_FSharp.Compiler.Service_Release_netstandard2.0.bsl
index cd2141db4..9de22b5cd 100644
--- a/tests/ILVerify/ilverify_FSharp.Compiler.Service_Release_netstandard2.0.bsl
+++ b/tests/ILVerify/ilverify_FSharp.Compiler.Service_Release_netstandard2.0.bsl
@@ -33,7 +33,7 @@
[IL]: Error [StackUnexpected]: : <StartupCode$FSharp-Compiler-Service>.$FSharpCheckerResults+GetReferenceResolutionStructuredToolTipText@2205::Invoke([FSharp.Core]Microsoft.FSharp.Core.Unit)][offset 0x00000076][found Char] Unexpected type on the stack.
[IL]: Error [StackUnexpected]: : FSharp.Compiler.EditorServices.AssemblyContent+traverseMemberFunctionAndValues@176::Invoke([FSharp.Compiler.Service]FSharp.Compiler.Symbols.FSharpMemberOrFunctionOrValue)][offset 0x0000002B][found Char] Unexpected type on the stack.
[IL]: Error [StackUnexpected]: : FSharp.Compiler.EditorServices.AssemblyContent+traverseEntity@218::GenerateNext([S.P.CoreLib]System.Collections.Generic.IEnumerable`1<FSharp.Compiler.EditorServices.AssemblySymbol>&)][offset 0x000000BB][found Char] Unexpected type on the stack.
-[IL]: Error [StackUnexpected]: : FSharp.Compiler.EditorServices.ParsedInput+visitor@1423-11::VisitExpr([FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<FSharp.Compiler.Syntax.SyntaxNode>, [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.SynExpr,Microsoft.FSharp.Core.FSharpOption`1<FSharp.Compiler.EditorServices.CompletionContext>>, [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.SynExpr,Microsoft.FSharp.Core.FSharpOption`1<FSharp.Compiler.EditorServices.CompletionContext>>, [FSharp.Compiler.Service]FSharp.Compiler.Syntax.SynExpr)][offset 0x00000618][found Char] Unexpected type on the stack.
+[IL]: Error [StackUnexpected]: : FSharp.Compiler.EditorServices.ParsedInput+visitor@1423-11::VisitExpr([FSharp.Core]Microsoft.FSharp.Collections.FSharpList`1<FSharp.Compiler.Syntax.SyntaxNode>, [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.SynExpr,Microsoft.FSharp.Core.FSharpOption`1<FSharp.Compiler.EditorServices.CompletionContext>>, [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<FSharp.Compiler.Syntax.SynExpr,Microsoft.FSharp.Core.FSharpOption`1<FSharp.Compiler.EditorServices.CompletionContext>>, [FSharp.Compiler.Service]FSharp.Compiler.Syntax.SynExpr)][offset 0x00000620][found Char] Unexpected type on the stack.
[IL]: Error [StackUnexpected]: : <StartupCode$FSharp-Compiler-Service>.$ServiceLexing+clo@921-523::Invoke([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<System.Tuple`3<FSharp.Compiler.Parser+token,int32,int32>,Microsoft.FSharp.Core.Unit>)][offset 0x00000032][found Char] Unexpected type on the stack.
[IL]: Error [StackUnexpected]: : <StartupCode$FSharp-Compiler-Service>.$ServiceLexing+clo@921-523::Invoke([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<System.Tuple`3<FSharp.Compiler.Parser+token,int32,int32>,Microsoft.FSharp.Core.Unit>)][offset 0x0000003B][found Char] Unexpected type on the stack.
[IL]: Error [StackUnexpected]: : <StartupCode$FSharp-Compiler-Service>.$ServiceLexing+clo@921-523::Invoke([FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<System.Tuple`3<FSharp.Compiler.Parser+token,int32,int32>,Microsoft.FSharp.Core.Unit>)][offset 0x00000064][found Char] Unexpected type on the stack. ILVerify will always need to run on an up-to-date proto and product compilers, because it always does a clean build in the CI, but not locally if not built from clean state. So Meanwhile, I've pushed baseline changes. |
Hah, it's green now. Thank you @vzarytovskii. |
Alright, getting this in. Thanks Martin for dealing with annoying edge cases / races. |
* Backport :: Bugfix :: Support `ldelem.u8`, `ldelem.u` opcode aliases (#18081) (#18096) * Streamlining test deps a bit (#18022) * Streamlining test deps a bit * up * Format ILVerify output a bit (#18120) * fix for race condition in FileIndex.fileIndexOfFile (#18008) * fix for race condition in FileIndex.fileIndexOfFile * fantomas * fixed ilverify baselines (just a single line number changed) * add release notes entry * FileToIndex: Added unlocked read so that lock is entered for new files only * update ilverify baselines (changed line numbers only) * Fix ILVerify --------- Co-authored-by: Petr <psfinaki@users.noreply.github.com> Co-authored-by: Vlad Zarytovskii <vzaritovsky@hotmail.com> * Update F# build version to 200 * Fix how much is trimmed from an interp string part (#18123) * Fix how much is trimmed from an interp string part Only trim last 2 characters if they are "%s" and the '%' is not escaped * Add release note --------- Co-authored-by: Adam Boniecki <abonie@users.noreply.github.com> * Sink: report SynPat.ArrayOrList type (#18127) --------- Co-authored-by: Tomas Grosup <tomasgrosup@microsoft.com> Co-authored-by: Petr <psfinaki@users.noreply.github.com> Co-authored-by: Martin <29605222+Martin521@users.noreply.github.com> Co-authored-by: Vlad Zarytovskii <vzaritovsky@hotmail.com> Co-authored-by: Adam Boniecki <20281641+abonie@users.noreply.github.com> Co-authored-by: Adam Boniecki <abonie@users.noreply.github.com> Co-authored-by: Alex Berezhnykh <alexey.berezhnykh@jetbrains.com> Co-authored-by: Kevin Ransom (msft) <codecutter@hotmail.com>
Description
Here is a fix for another ancient bug that I found while working on "scoped nowarn".
It took a while to find the culprit.
There is a race condition in
FileIndex.fileIndexOfFile
that can lead to different indices for the same file.This PR contains the fix and a regression test.