Commit 23958ba
committed
fix: deadlock using IRB integration on Rails applications
When using `debugger` in a rails console using IRB integration, the second `continue` causes a fatal deadlock:
"No live threads left. Deadlock?"
The root cause is that `leave_subsession` pops `@subsession_stack` and sets `@tc = nil`
before `thread_stopper.disable` takes full effect. In that window, the
thread_stopper TracePoint fires on the main thread (back in IRB's eval loop),
and since `@tc` is nil, the guard `tc == @tc` no longer protects it. The main
thread is paused via `on_pause`, but the session server is already blocked on
`@q_evt.pop` -- neither can wake the other.
The fix for this is addiing `next unless in_subsession?` as the first guard in thread_stopper.
Once `leave_subsession` has popped the stack, in_subsession? returns false
and the TracePoint becomes a no-op even if it hasn't been disabled yet.1 parent 2897eda commit 23958ba
1 file changed
+9
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1678 | 1678 | | |
1679 | 1679 | | |
1680 | 1680 | | |
| 1681 | + | |
| 1682 | + | |
| 1683 | + | |
| 1684 | + | |
| 1685 | + | |
| 1686 | + | |
| 1687 | + | |
| 1688 | + | |
| 1689 | + | |
1681 | 1690 | | |
1682 | 1691 | | |
1683 | 1692 | | |
| |||
0 commit comments