-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modify buffer overflow logic for System.Buffers.ArrayPool.Tests.ArrayPoolUnitTests.ReturnBufferWhenFullFiresDroppedDiagnosticEvent #112849
Conversation
…ferWhenFullFiresDroppedDiagnosticEvent' fails on systems with cpu cores >= 32. The test begins by renting from a SharedArrayPool 1 byte using the 'Rent' function for 1000 iterations and returning the bytes rented using the 'Return' function back to the SharedArrayPool. The test expects that returning a large number of bytes(in this case 1000) overflows the SharedArrayPool hence dropping it. The test case fails in machines that have cpu cores greater than 32 because the capacity of the SharedArrayPool is dependent on the number of processors. It happens to be 'number of processors' * 32. Clearly the size of the SharedArrayPool in case of 32 cpu cores would be 32*32=1024 which is greater than 1000 and hence doesn't overflow the SharedArrayPool and hence failing test case. We actualy need ('number of processors' * 32 + 2) iterations because ('number of processors' * 32 + 1) bytes would be required to overflow the buffer and the ith iteration actually caches the byte to TLA and push the (i-1)th byte to the pool. Hence ('number of processors + 32' + 1)th byte would be returned on the ('number of processors + 32' + 2)nd iterations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Tagging subscribers to this area: @dotnet/area-system-buffers |
@stephentoub Can you review this please. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
background failures seem to be unrelated. |
Yes. But what is the urgency? |
The test 'System.Buffers.ArrayPool.Tests.ArrayPoolUnitTests.ReturnBufferWhenFullFiresDroppedDiagnosticEvent' fails on systems with cpu cores >= 32.
The test begins by renting from a SharedArrayPool 1 byte using the 'Rent' function for 1000 iterations and returning the bytes rented using the 'Return' function back to the SharedArrayPool.
The test expects that returning a large number of bytes(in this case 1000) overflows the SharedArrayPool hence dropping it. The test case fails in machines that have cpu cores greater than 32 because the capacity of the SharedArrayPool is dependent on the number of processors. It happens to be 'number of processors' * 32.
The size of the SharedArrayPool in case of 32 cpu cores would be 32*32=1024 which is greater than 1000 and hence doesn't overflow the SharedArrayPool and hence failing test case. We actualy need ('number of processors' * 32 + 2) iterations because ('number of processors' * 32 + 1) bytes would be required to overflow the buffer and the ith iteration actually caches the byte to TLA and push the (i-1)th byte to the pool. Hence ('number of processors + 32' + 1)th byte would be returned on the ('number of processors + 32' + 2)nd iteration. see link