Open
Description
Below is an example of a deadlock that was seen.
Thread 1:
- Enters a concurrent queue's cross-segment lock here
- OOM exception occurs here in array allocation
MemoryCache
's unhandled exception handler runs, disposes stats, disposes timer, which tries to enter aTimerQueue
lock here and blocks because Thread 2 holds the lock
Thread 2:
- Enters the
TimerQueue
lock here - Tries to queue a timer callback, which tries to enter the concurrent queue's cross-segment lock here and blocks because Thread 1 holds the lock
The two threads are deadlocked. Unhandled exceptions can occur in arbitrary places and there may also be other cases. A solution could be to not dispose the timer on the unhandled exception path.