New hard crash after targeting .net 9 from 8 (System.AccessViolationException) #110543
Description
Description
With .NET 9 I started getting System.AccessViolationException crashes in a .NET MAUI application that was rock solid before the upgrade. The issue is inside a function that reads and sums arrays of longs in parallel using Enumberable.Sum though I am not able to reproduce the issue in debug mode yet. All crashes have occurred on the release build. The program runs the function that throws this error twice each millisecond and will run for anywhere from 25 minutes to 2 hours without it encountering the error. An example message is at the bottom of this post because while writing this post I got a new crash reason:
Application: MyMauiApp.exe
CoreCLR Version: 9.0.24.52809
.NET Version: 9.0.0
Description: The process was terminated due to an internal error in the .NET Runtime at IP 0x00007FFE80BBEA8B (0x00007FFE808D0000) with exit code 0xc0000096.
Previous Crash Errors:
CoreCLR Version: 9.0.24.52809
.NET Version: 9.0.0
Description: The process was terminated due to an unhandled exception.
Exception Info: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Stack:
at System.Runtime.ExceptionServices.InternalCalls.g____PInvoke|0_0(System.Runtime.StackFrameIterator*, Void*, Int32, Boolean*)
at System.Runtime.ExceptionServices.InternalCalls.g____PInvoke|0_0(System.Runtime.StackFrameIterator*, Void*, Int32, Boolean*)
at System.Runtime.EH.DispatchEx(System.Runtime.StackFrameIterator ByRef, ExInfo ByRef)
at System.Runtime.EH.RhThrowHwEx(UInt32, ExInfo ByRef)
at MyNamespace.MyClass+<>c__DisplayClass96_0.b__0(Int32)
at System.Threading.Tasks.Parallel+<>c__DisplayClass19_0`2[[System.__Canon, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Int32, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].b__1(System.Threading.Tasks.RangeWorker ByRef, Int64, Boolean ByRef)
at System.Threading.Tasks.TaskReplicator+Replica.Execute()
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(System.Threading.Thread, System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(System.Threading.Tasks.Task ByRef, System.Threading.Thread)
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool+WorkerThread.WorkerThreadStart()
Reproduction Steps
I do not have the minimum steps at this time.
Expected behavior
Keep running and throw a catchable exception inside the app that my default handlers could process.
Actual behavior
Program closes and writes an event to EventViewer
Regression?
Did not occur in .NET 8
Known Workarounds
No response
Configuration
No response
Other information
No response
Activity