Steps:
- Create new .Net 9 project and put code in Visual Studio 2022
using System.Collections.Concurrent;
var breakingBadHoleInTheBag = new ConcurrentBag<ConcurrentBagItem>();
int tries = 500000;
while (tries-- > 0)
{
breakingBadHoleInTheBag.SingleOrDefault(x => x == (object)breakingBadHoleInTheBag);
breakingBadHoleInTheBag.Add(new ConcurrentBagItem());
}
class ConcurrentBagItem { }
- Execute with or without debugger
Actual result:
An unhandled exception of type 'System.AccessViolationException' occurred in System.Collections.Concurrent.dll
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Expected result:
Works without error, as in .Net 9.
Please introduce ConcurrentBag - from .Net 8 because uinstable work in .Net 9 breaks my app