The blog post discusses a situation in Haskell where a thread trying to read from a TMVar cannot make progress and is considered “stalled.” This can occur when the TMVar is empty and there are no other threads that could write to it. The GHC runtime detects this and throws a BlockedIndefinitelyOnSTM exception. However, there are cases where the runtime throws this exception even when progress is possible. This behavior can be confusing and can lead to unexpected outcomes. The post explores when and how this can happen and suggests workarounds to handle the issue. It also discusses the detection of stalled threads and provides insights into the GC algorithm used in Haskell. The author acknowledges that relying on deadlock detection for program correctness is not ideal and recommends finding reliable workarounds.
https://well-typed.com/blog/2024/01/when-blocked-indefinitely-is-not-indefinite/