-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent endless loop in lock cycle detection. The following scenario …
…would previously fail: * T1: Enter `lockOrDetectPotentialLocksCycle`: - Lock CAF.class, add itself to `lockThreadIsWaitingOn`, unlock CAF.class - Lock the cycle detecting lock (CDL) - Lock CAF.class, mark itself as `lockOwnerThread`, remove itself from `lockThreadIsWaitingOn` - Exit `lockOrDetectPotentialLocksCycle` * T1: Re-enter `lockOrDetectPotentialLocksCycle`: - Lock CAF.class, add itself to `lockThreadIsWaitingOn`, unlock CAF.class T2: Enter `lockOrDetectPotentialLocksCycle` - Lock CAF.class, invoke `detectPotentialLocksCycle`. At this point, `detectPotentialLocksCycle` will now loop forever, because the `lockOwnerThread` is also in `lockThreadIsWaitingOn`. During the course of looping forever, it will OOM, because it's building up an in-memory structure of what it thinks are cycles. The solution is to avoid the re-entrant T1 from adding itself to `lockThreadIsWaitingOn` if it's already the `lockOwnerThread`. It's guaranteed that it won't relinquish the lock concurrently, because it's the exact same thread that owns it. Fixes #1635 and Fixes #1510 PiperOrigin-RevId: 524376697
- Loading branch information
Showing
2 changed files
with
56 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters