Description
After updating my project from .NET 8 to .NET 9 my application started to crash randomly, I couldn't get any logs as to why it was crashing so I took a full dump when it crashed. It appears it's crashing after I call ToFrozenDictionary on a dictionary.
Here's the full error message:
Unhandled exception at 0x00007FFB075EB7A3 (System.Collections.Immutable.dll) in JL.exe.33024.dmp: 0xC0000005: Access violation writing location 0x0000044D37D1C080.
You can find the dump file in https://developercommunity.visualstudio.com/t/Random-Access-violation-writing-locatio/10820014
EDIT: I've found out I got an Unhandled exception at 0x00007FFAF8C3F18E (System.Private.CoreLib.dll) in JL.exe.15332.dmp: 0xC0000005: Access violation reading location 0x0000000041F9FA2A
error a day before that resulted in a crash, added the dump file for it in the aforementioned link since it seems related.
Reproduction Steps
It appears to happen pretty rarely and randomly so I wasn't able to produce minimized reproduction steps. Hopefully the dump file can shed some light as to why it's happening.
Expected behavior
Calling ToFrozenDictionary does not produce an unhandled exception and does not crash the app
Actual behavior
Calling ToFrozenDictionary produces an unhandled exception and crashes the app
Regression?
Yes, I've never encountered this error before updating from .NET 8 to .NET 9
Known Workarounds
No response
Configuration
.NET 9, Windows 10 22H2 x64
Other information
No response