dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.42k stars 4.76k forks source link

AccessViolationException sometimes happens in F# compiler #110012

Closed 0101 closed 1 day ago

0101 commented 1 day ago

Description

F# compiler sometimes crashes for me when compiling projects (in the fsharp repo itself).

Here's the dump from the process: https://microsofteur-my.sharepoint.com/:u:/g/personal/petrpokorny_microsoft_com/ETWIINZkTGBIiQx8ob4KIzoBdoAidVakBTvexFGPNnv_BQ?e=gMb5If

I cannot really tell what causes the exception.

Reproduction Steps

git clone dotnet/fsharp

build.cmd -c Debug

Expected behavior

fsc.exe doesn't crash

Actual behavior

fsc.exe sometimes crashes

Regression?

Yes

Known Workarounds

Try again.

Configuration

Windows SDK 9.0.100

Other information

This thread's stack trace seems suspicious, probably that's where the AVE happened?

. 37  Id: 6808.10414 Suspend: 0 Teb: 000000e2`4b13a000 Unfrozen ".NET TP Worker"
      Start: coreclr!ThreadNative::KickOffThread (00007ffd`2b3b5160)
      Priority: 0  Priority class: 32  Affinity: ffff
 # Child-SP          RetAddr               Call Site
00 000000e2`4ffb6f88 00007ffd`c598c7af     ntdll!NtWaitForSingleObject+0x14
01 000000e2`4ffb6f90 00007ffd`2b4ec910     KERNELBASE!WaitForSingleObjectEx+0xaf
02 000000e2`4ffb7030 00007ffd`2b4e8ec0     coreclr!LaunchCreateDump+0xe0 [D:\a\_work\1\s\src\coreclr\vm\excep.cpp @ 3856] 
03 000000e2`4ffb7170 00007ffd`2b4f0038     coreclr!CreateCrashDumpIfEnabled+0x80 [D:\a\_work\1\s\src\coreclr\vm\excep.cpp @ 3891] 
04 000000e2`4ffb71c0 00007ffd`2b52d224     coreclr!WatsonLastChance+0x198 [D:\a\_work\1\s\src\coreclr\vm\excep.cpp @ 3587] 
05 000000e2`4ffb7230 00007ffd`2b52c40b     coreclr!EEPolicy::LogFatalError+0x6b4 [D:\a\_work\1\s\src\coreclr\vm\eepolicy.cpp @ 589] 
06 000000e2`4ffb7ef0 00007ffd`2b4b146a     coreclr!EEPolicy::HandleFatalError+0x133 [D:\a\_work\1\s\src\coreclr\vm\eepolicy.cpp @ 828] 
07 000000e2`4ffb84f0 00007ffd`2b3dd754     coreclr!FailFastIfCorruptingStateException+0xd364a [D:\a\_work\1\s\src\coreclr\vm\exceptionhandling.cpp @ 8217] 
08 000000e2`4ffb85d0 00007ffd`1e4e7892     coreclr!SfiInit+0x114 [D:\a\_work\1\s\src\coreclr\vm\exceptionhandling.cpp @ 8367] 
09 000000e2`4ffb8650 00007ffd`1e4e73fa     System_Private_CoreLib!System.Runtime.EH.DispatchEx+0xf2
0a 000000e2`4ffb87b0 00007ffd`2b4369a3     System_Private_CoreLib!System.Runtime.EH.RhThrowHwEx+0xaa
0b 000000e2`4ffb87f0 00007ffd`2b3954c8     coreclr!CallDescrWorkerInternal+0x83 [D:\a\_work\1\s\src\coreclr\vm\amd64\CallDescrWorkerAMD64.asm @ 74] 
0c 000000e2`4ffb8830 00007ffd`2b4ebe2a     coreclr!DispatchCallSimple+0x60 [D:\a\_work\1\s\src\coreclr\vm\callhelpers.cpp @ 248] 
0d 000000e2`4ffb88c0 00007ffd`2b4c3b78     coreclr!HandleManagedFaultNew+0x192 [D:\a\_work\1\s\src\coreclr\vm\excep.cpp @ 6304] 
0e 000000e2`4ffba3d0 00007ffd`c807ed36     coreclr!CLRVectoredExceptionHandlerShim+0xaa978 [D:\a\_work\1\s\src\coreclr\vm\excep.cpp @ 7282] 
0f 000000e2`4ffba420 00007ffd`c807f13e     ntdll!RtlpCallVectoredHandlers+0xd6
10 000000e2`4ffba4b0 00007ffd`c81c36de     ntdll!RtlDispatchException+0xae
11 000000e2`4ffba700 00007ffc`cb740046     ntdll!KiUserExceptionDispatch+0x2e
12 000000e2`4ffbb458 00007ffd`899d85a1     0x00007ffc`cb740046
13 000000e2`4ffbb460 00007ffd`15427784     System_Collections!System.Collections.Generic.Stack<TokenTup>.Push+0x21 [/_/src/libraries/System.Collections/src/System/Collections/Generic/Stack.cs @ 274] 
14 000000e2`4ffbb4a0 00007ffd`154353e2     FSharp_Compiler_Service!FSharp.Compiler.LexFilter.LexFilterImpl.hwTokenFetch+0x19cb4
15 000000e2`4ffbe180 00007ffc`cc2c561c     FSharp_Compiler_Service!FSharp.Compiler.LexFilter.LexFilter.GetToken+0x32
16 000000e2`4ffbe1b0 00007ffd`15452619     FSharp_Compiler_Service!Internal.Utilities.Text.Parsing.Implementation.interpret<token>+0x113c
17 000000e2`4ffbec80 00007ffd`14fbc2d8     FSharp_Compiler_Service!FSharp.Compiler.Parser.implementationFile+0x39
18 000000e2`4ffbecc0 00007ffd`14fc22d8     FSharp_Compiler_Service!FSharp.Compiler.ParseAndCheckInputs.ParseInput+0x4c8
19 000000e2`4ffbedc0 00007ffc`cc29852c     FSharp_Compiler_Service!FSharp.Compiler.ParseAndCheckInputs.ParseOneInputLexbuf@633.Invoke
1a 000000e2`4ffbee80 00007ffc`cc298495     FSharp_Compiler_Service!FSharp.Compiler.Lexhelp.reusingLexbufForParsing<FSharp.Compiler.Syntax.ParsedInput>+0x6c
1b 000000e2`4ffbefc0 00007ffd`14fbcf46     FSharp_Compiler_Service!FSharp.Compiler.Lexhelp.usingLexbufForParsing<FSharp.Compiler.Syntax.ParsedInput>+0x105
1c 000000e2`4ffbf060 00007ffd`14fbd540     FSharp_Compiler_Service!FSharp.Compiler.ParseAndCheckInputs.ParseOneInputLexbuf+0x1e6
1d 000000e2`4ffbf120 00007ffd`14fc2479     FSharp_Compiler_Service!FSharp.Compiler.ParseAndCheckInputs.parseInputFileAux+0xc0
1e 000000e2`4ffbf1a0 00007ffd`156c1abd     FSharp_Compiler_Service!FSharp.Compiler.ParseAndCheckInputs.ParseInputFilesInParallel@830-1.Invoke
1f 000000e2`4ffbf230 00007ffc`cc2973a1     FSharp_Compiler_Service!
20 000000e2`4ffbf270 00007ffd`7bd96c57     System_Threading_Tasks_Parallel!System.Threading.Tasks.Parallel.<>c__DisplayClass19_0<object,int>.<ForWorker>b__1+0x371
21 000000e2`4ffbf3d0 00007ffd`1e49c462     System_Threading_Tasks_Parallel!System.Threading.Tasks.TaskReplicator.Replica.Execute+0x87
22 000000e2`4ffbf430 00007ffd`1e4b8201     System_Private_CoreLib!System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop+0x42
23 000000e2`4ffbf480 00007ffd`1e4a6eed     System_Private_CoreLib!System.Threading.Tasks.Task.ExecuteWithThreadLocal+0x91
24 000000e2`4ffbf520 00007ffd`1e4b3811     System_Private_CoreLib!System.Threading.ThreadPoolWorkQueue.Dispatch+0x31d
25 000000e2`4ffbf5b0 00007ffd`2b4369a3     System_Private_CoreLib!System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart+0xf1
26 000000e2`4ffbf6c0 00007ffd`2b3954c8     coreclr!CallDescrWorkerInternal+0x83 [D:\a\_work\1\s\src\coreclr\vm\amd64\CallDescrWorkerAMD64.asm @ 74] 
27 000000e2`4ffbf700 00007ffd`2b424f53     coreclr!DispatchCallSimple+0x60 [D:\a\_work\1\s\src\coreclr\vm\callhelpers.cpp @ 248] 
28 000000e2`4ffbf790 00007ffd`2b3b5131     coreclr!ThreadNative::KickOffThread_Worker+0x63 [D:\a\_work\1\s\src\coreclr\vm\comsynchronizable.cpp @ 158] 
29 (Inline Function) --------`--------     coreclr!ManagedThreadBase_DispatchInner+0xd [D:\a\_work\1\s\src\coreclr\vm\threads.cpp @ 7110] 
2a 000000e2`4ffbf7f0 00007ffd`2b3b504b     coreclr!ManagedThreadBase_DispatchMiddle+0x81 [D:\a\_work\1\s\src\coreclr\vm\threads.cpp @ 7154] 
2b 000000e2`4ffbf8a0 00007ffd`2b3b51de     coreclr!ManagedThreadBase_DispatchOuter+0xab [D:\a\_work\1\s\src\coreclr\vm\threads.cpp @ 7313] 
2c (Inline Function) --------`--------     coreclr!ManagedThreadBase_FullTransition+0x28 [D:\a\_work\1\s\src\coreclr\vm\threads.cpp @ 7358] 
2d (Inline Function) --------`--------     coreclr!ManagedThreadBase::KickOff+0x28 [D:\a\_work\1\s\src\coreclr\vm\threads.cpp @ 7393] 
2e 000000e2`4ffbf940 00007ffd`c625dbe7     coreclr!ThreadNative::KickOffThread+0x7e [D:\a\_work\1\s\src\coreclr\vm\comsynchronizable.cpp @ 230] 
2f 000000e2`4ffbf9a0 00007ffd`c813fbec     kernel32!BaseThreadInitThunk+0x17
30 000000e2`4ffbf9d0 00000000`00000000     ntdll!RtlUserThreadStart+0x2c
jkotas commented 1 day ago

Crash on return from a method that tail called System.Runtime.CompilerServices.CastHelpers.StelemRef.

Duplicate of https://github.com/dotnet/runtime/issues/108763. Backport to .NET 9 is in progress: https://github.com/dotnet/runtime/pull/109548.

cc @janvorli