Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent endless loop in lock cycle detection #1510 #1635

Closed
wants to merge 1 commit into from

Commits on Jun 11, 2022

  1. This change prevents an endless loop in: ReentrantCycleDetectingLock.…

    …detectPotentialLocksCycle()
    
    Due to how code in ReentrantCycleDetectingLock.lockOrDetectPotentialLocksCycle() is synchronized,
    its possible for a thread to both own/hold a lock (according to ReentrantCycleDetectingLock.lockOwnerThread)
    and wait on the same lock (according to CycleDetectingLock.lockThreadIsWaitingOn).
    In this state, if another thread tries to hold the same lock an endless loop will occur when calling detectPotentialLocksCycle().
    
    With this change detectPotentialLocksCycle() removes the lock owning thread from
    ReentrantCycleDetectingLock.lockOwnerThread,
    if it detects that "this" lock is both waited on and owned by the same thread.
    This prevents the endless loop during cycle detection.
    
    Fix for: google#1510
    trancexpress committed Jun 11, 2022
    Configuration menu
    Copy the full SHA
    f48f54c View commit details
    Browse the repository at this point in the history