Thanks to visit codestin.com
Credit goes to github.com

Skip to content

OrderedWalk is not thread-safe #40

@zioc

Description

@zioc

Calling OrderedWalk alongside with other dag operations may lead to deadlock as described in this issue

OrderedWalk acquires an RLock and calls GetParents that is also acquiring an RLock.

This may lead to deadlocks if another goroutine acquires a RWLock in the meantime. The rwmutex documentation clearly explains that pitfall:

If any goroutine calls RWMutex.Lock while the lock is already held by one or more readers,
concurrent calls to RWMutex.RLock will block until the writer has acquired (and released) the lock,
to ensure that the lock eventually becomes available to the writer. Note that this prohibits
recursive read-locking. A RWMutex.RLock cannot be upgraded into a RWMutex.Lock, nor can a
RWMutex.Lock be downgraded into a RWMutex.RLock.

Rlock function doc also explicitely stands that:

It should not be used for recursive read locking; a blocked Lock
call excludes new readers from acquiring the lock. See the
documentation on the [RWMutex] type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions