fsi --typecheck-only sometimes deadlocks on TcImports locks while registering referenced assemblies (SDK 10.0.403)
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Start by reading the lock-invariant audit in #20804 and the deadlock reference in PR #16779, then trace RegisterAndImportReferencedAssemblies, registerDll, and the TcImports calls named in the stack traces. Try to reproduce the lock cycle with concurrent dotnet fsi --typecheck-only runs over scripts with many referenced assemblies. Done means the deadlock is fixed and the concurrent typecheck workload completes reliably.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Drafted with Claude Code (automated). Reviewed and filed on behalf of the reporter.
Summary
dotnet fsi --typecheck-only sometimes deadlocks while it registers referenced assemblies, when many fsi processes run at the same time. The hung process uses 0% CPU. Its thread-pool threads wait on Monitor.Enter inside TcImports, and other threads hold those locks and wait in Async.RunSynchronously. Each process runs alone, so the processes do not share state. The deadlock is inside one process, and load only makes it more likely.
Environment
- .NET SDK 10.0.403,
Microsoft (R) F# Interactive version 15.2.403.0 for F# 10.0 - Windows 11 x64, 24 logical processors, 64 GB
- Each script references about 20 project assemblies with
#r(found through--lib:<folder>and#I) and#loads several other scripts, some of which declare anamespaceand load.paket/loadpackage scripts.
How it shows
A build tool runs dotnet fsi --typecheck-only <script>.fsx for about 280 scripts, 24 processes at a time. Alone, each script type-checks in about 10 to 40 seconds.
- In each full run, 1 to 4 processes out of 100 to 300 never finish.
- A different script hangs on each run. The hung script passes when it runs again alone.
- A hung process used 0 s of CPU over 15 s, and it had 57 threads.
DOTNET_ThreadPool_ForceMinWorkerThreads=40(64 worker threads) did not stop the hangs, so this is a lock cycle, not thread-pool starvation.
The workaround in our tool is a 3-minute timeout and one retry for each script.
Stacks of a hung process (dotnet-stack report, grouped)
Main thread:
FSharpAsync.RunSynchronously
<- CompilerImports.RequireReferences
<- FsiDynamicCompiler.ProcessDelayedReferences
<- FsiDynamicCompiler.EvalSourceFiles
<- FsiInteractionProcessor.PartiallyProcessHashDirective
<- ... <- FsiInteractionProcessor.LoadInitialFiles <- FsiEvaluationSession.Run
Thread-pool threads waiting for a lock:
4x Monitor.Enter <- TcImports.OpenILBinaryModule <- tryGetAssemblyData
2x Monitor.Enter <- CompilerImports.look <- fixupThunk <- PickledDataWithReferences.OptionalFixup
<- PrepareToImportReferencedFSharpAssembly <- registerDll
1x Monitor.Enter <- fixupThunk <- PickledDataWithReferences.OptionalFixup
<- PrepareToImportReferencedFSharpAssembly <- registerDll
1x Monitor.Enter <- TcImports.PrepareToImportReferencedILAssembly <- registerDll
<- RegisterAndImportReferencedAssemblies
1x Monitor.Enter <- TcImports.RegisterCcu <- TcImports.PrepareToImportReferencedFSharpAssembly <- registerDll
1x Monitor.Enter <- TcImports.TryResolveAssemblyReference <- tryFile
<- TcImports.ImplicitLoadIfAllowed <- fixupThunk <- PickledDataWithReferences.OptionalFixup
Thread-pool threads waiting for an async result while they hold their caller's locks:
13x FSharpAsync.RunSynchronously <- CompilerImports.tryFile
<- TcImports.ImplicitLoadIfAllowed <- fixupThunk <- PickledDataWithReferences.OptionalFixup
<- PrepareToImportReferencedFSharpAssembly <- registerDll
registerDll runs on several pool threads at once. While a thread fixes up a pickled F# assembly, ImplicitLoadIfAllowed calls tryFile, which blocks in Async.RunSynchronously on work that needs a TcImports lock that another registering thread holds.
Related
- #20804 (audit of lock invariants now that checking is concurrent)
- PR #16779 mentions a deadlock in
RegisterAndImportReferencedAssemblieswhen FSI calls it.
I do not have a minimal public repro yet, because the hang is random and needs many referenced F# assemblies. I can capture a full dump of a hung process if that helps.
- Ngôn ngữ chính
- F#
- Star
- 4.3k
- Fork
- 884
- Merge trung bình
- 2 ngày 11 giờ
- Pull request đã merge (30 ngày)
- 73
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của dotnet/fsharp
-
Needs-Triage
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 95/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Semantic classification cache for opened documents is never populated (written to the unopened-documents cache)Có thể đã có người làm @xperiandri đã nhận 69 ngày trước. Đang mởNeeds-Triage
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Needs-Triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
dotnet/fsharp#20265 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Bug Needs-Triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Needs-Triage
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của dotnet/fsharp
Issue tương tự
-
Mend: dependency security vulnerability
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 65/100
fdm-monster/fdm-monster#5563 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
aws/aws-emulator#345 ·
-
AI bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
AUTO-MAS-Project/AUTO-MAS#1960 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
btclib-org/btclib-wallet#872 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
be-BOP-io-SA/be-BOP#2849 ·