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
It's expected that the following assert, that checks that the rented array is cleared, always succeeds:
Assert.True(a.Take(ArrayLength).All(e =>e==0));
Actual behavior
The assert sometimes fails
Regression?
No response
Known Workarounds
No response
Configuration
SDK .net 9.0.101
Windows 10 22H2
Other information
Maybe the cause is that ArrayPool.Shared is thread-safe, since the shared implementation stores the array instances in a ThreadStatic structure. But it's not "await/task safe" as a task could switch the thread it's executing on.
The text was updated successfully, but these errors were encountered:
The shared array pool is used by a lot of components, including LINQ. Other components can return uncleared array into the pool and get rented by your code.
Code shouldn't depend on existing content of rented array. In the proposed stress debug mode, the pool will always fill the array with garbage.
The shared array pool is used by a lot of components, including LINQ. Other components can return uncleared array into the pool and get rented by your code.
Code shouldn't depend on existing content of rented array. In the proposed stress debug mode, the pool will always fill the array with garbage.
It also currently uses GC.AllocateUninitializedArray when a new array is needed:
Description
With a high number of tasks,
ArrayPool.Shared.Return()
, with theclearArray
argument set to true, fails to clear the arrayReproduction Steps
Unit test:
Expected behavior
It's expected that the following assert, that checks that the rented array is cleared, always succeeds:
Actual behavior
The assert sometimes fails
Regression?
No response
Known Workarounds
No response
Configuration
SDK .net 9.0.101
Windows 10 22H2
Other information
Maybe the cause is that ArrayPool.Shared is thread-safe, since the shared implementation stores the array instances in a ThreadStatic structure. But it's not "await/task safe" as a task could switch the thread it's executing on.
The text was updated successfully, but these errors were encountered: