-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
Possible race condition in System.IO.Pipelines: InvalidCastException in (System.Memory's)System.Buffers.ReadOnlySequence.GetFirstBuffer #27580
Comments
Today I ran this again, and this time I got an NRE: https://gist.github.com/knocte/cb5c54f8454c42bc3853de4e9af00736 (Note that this a copy+paste from the console, given that the exception dialog didn't let me copy the exception details. To get the exception in the console I had to do this before the
And I also noticed that there was a new version of System.IO.Pipelines, so I upgraded from 4.5.0 and 4.5.2, ran it again, and the problem is still not solved:
|
Note that while I can reproduce this consistently (100% of the times) when debugging with an Android phone (either with VS2017 or VSforMac), the bug doesn't happen when debugging with the Android emulator. |
Even if I haven't upgraded any nuget packages recently in my solution (at least not later than my latest comments on the 19th of October), somehow this exception has now morphed into another one (maybe because I upgraded my VisualStudioForMac and XamarinAndroid to latest stable versions recently?). Now the exception is an InvalidCastException inside
By looking at the sources, it' seems there's only one cast in that method: At least now the problem seems more localized. |
@knocte, are you able to reproduce the issue with the latest versions of the packages? |
@knocte are you still seeing this? |
TBH I cannot answer that because now I'm being affected by an IDE bug :( : https://github.com/mono/monodevelop/issues/8552 |
I haven't seen this in a big while. |
I have a System.IO.Pipelines-based TCP client written here.
The client works normally in RELEASE mode and when running under integration tests. However I have found that under certain slower conditions (debugging in an Android phone), an exception happens in
System.Buffers.BufferExtensions.PositionOf
:The area of the code where this happens is:
I've tried to guard the call to PositionOf by calling buffer.IsEmpty first (to not call PositionOf in case it's empty), but this results in a NullReferenceException (which is surprising given that buffer is of a struct type, so can't be null).
In the sources you see, the package versions used are:
System.Buffers: 4.5.0
System.IO.Pipelines 4.5.0
System.Memory 4.5.1
The text was updated successfully, but these errors were encountered: