Disable graph-based type checking for FSharp.Core#15838
Merged
0101 merged 2 commits intodotnet:mainfrom Aug 23, 2023
Merged
Conversation
nojaf
commented
Aug 22, 2023
T-Gro
approved these changes
Aug 23, 2023
vzarytovskii
approved these changes
Aug 23, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In recent days I've been seeing errors when compiling
FSharp.Core.fsprojusing the new--test:GraphBasedCheckingflag. (SDK8.0.100-preview.7.23376.3)I was able to reproduce this behaviour for multiple files in
FSharp.Corewhich leads me to suspect that this is a problem with mutable state, threads and a race condition.I'd like to stress that so far, I have not seen this behaviour outside of
FSharp.Core! Keeping that in mind, I've done some digging and found that the problem occurs whencompilingCanonicalFslibModuleTypeis true:fsharp/src/Compiler/Checking/CheckBasics.fs
Line 364 in 8a6a476
The error happens in
UpdateAccModuleOrNamespaceType,KeyNotFoundExceptioncan be raised for various modules:fsharp/src/Compiler/Checking/CheckExpressions.fs
Lines 1067 to 1075 in 3183d55
let modul = nleref.Derefcan raise an exception.It is my understanding that
fsharp/src/Compiler/Checking/CheckDeclarations.fs
Lines 4819 to 4825 in 681069f
fsharp/src/Compiler/TypedTree/TypedTreeOps.fs
Lines 1191 to 1212 in 6cb9792
should add some modules or namespaces that will later be found by
nleref.Deref. Because of the parallel nature, this appears to be no longer happening as expected. Hence theKeyNotFoundException.mtype.AddModuleOrNamespaceByMutation smodulclearly mutates the data infsharp/src/Compiler/TypedTree/TypedTree.fs
Lines 1996 to 2000 in 5483858
which I believe is unpredictable right now during
graphmode.I'm not quite sure about the exact details of what is transpiring here. If someone knows more about compiling
FSharp.Core, I'd be happy to chat/pair. For now, I propose disabling graph-based type-checking forFSharp.Core. Understandably, this is rather anti-climactic, but I'm not yet convinced the problem can occur outsideFSharp.Core, so this seems a sensible approach. As we already had a bit of a hack forFSharp.Core("prim-types-prelude.fsi"as a dependency for all files), maybe it is not meant to be.Anyway, I'm happy to hear your thoughts and collaborate.
//cc @safesparrow