-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Closed
Closed
Copy link
Labels
area-System.Net.Httptenet-reliabilityReliability/stability related issue (stress, load problems, etc.)Reliability/stability related issue (stress, load problems, etc.)
Milestone
Description
Description
After updating the application from Framework to .Net 8 we occasionally get the following exceptions:
System.IndexOutOfRangeException:
at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
at System.Net.HttpListener.RegisterForDisconnectNotification(HttpListenerSession session, UInt64 connectionId, DisconnectAsyncResult& disconnectResult)
at System.Net.HttpListener.HandleAuthentication(HttpListenerSession session, RequestContextBase memoryBlob, Boolean& stoleBlob)
at System.Net.ListenerAsyncResult.IOCompleted(ListenerAsyncResult asyncResult, UInt32 errorCode, UInt32 numBytes)
at System.Net.HttpListener.EndGetContext(IAsyncResult asyncResult)
System.InvalidOperationException:
at System.Collections.Generic.Dictionary`2.FindValue(TKey key)
at System.Net.HttpListener.HandleAuthentication(HttpListenerSession session, RequestContextBase memoryBlob, Boolean& stoleBlob)
at System.Net.ListenerAsyncResult.IOCompleted(ListenerAsyncResult asyncResult, UInt32 errorCode, UInt32 numBytes)
at System.Net.HttpListener.EndGetContext(IAsyncResult asyncResult)
After further investigation in the System.Net.HttpListener sourecode I found that the Dictionary DisconnectResults is not always used in a thread safe manner. It is missing lock around the access of DisconnectResults
Reproduction Steps
It is hard to reproduce. It happens randomly
Expected behavior
No exception
Actual behavior
Exceptions and possible internal corruption of HttpListener
Regression?
No response
Known Workarounds
I have fixed version of HttpListener (see patch). If this fix is stable for 1 week I will submit a pull request.
HttpListener-fix-Operations-that-change-non-concurre.patch
Configuration
No response
Other information
No response
Metadata
Metadata
Assignees
Labels
area-System.Net.Httptenet-reliabilityReliability/stability related issue (stress, load problems, etc.)Reliability/stability related issue (stress, load problems, etc.)