You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Win11] [Bug] [ConcurrentBag regression in .Net 9] System.AccessViolationException: 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.' #110355
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