Method and apparatus for detecting lock acquisition hierarchy violations and unsafe lock releases
First Claim
Patent Images
1. A method comprising:
- for a first thread which acquires a synchronization primitive, recording a set of currently-held synchronization primitives and a set of currently-acquired synchronization primitives;
indicating a possibly-unsafe lock release when the first thread releases a resource set s of resource set elements r and one or more of the resource set elements r of the resource set s was not among a plurality of resource set elements acquired by the first thread on entry to the synchronization primitive previously acquired by the first thread;
constructing a graph of connected nodes, where a node indicates the set of currently-held synchronization primitives and the set of currently-acquired synchronization primitives;
searching the graph for a node to indicate the set of currently-held synchronization primitives and the set of currently-acquired synchronization primitives; and
searching for a lock acquisition hierarchy violation, in which a second thread acquires a partial acquisition hierarchy of the synchronization primitive previously acquired by the first thread, wherein searching for a lock acquisition hierarchy violation comprises searching for a cycle in the graph;
reporting the lock acquisition hierarchy violation; and
reporting the possibly-unsafe lock release.
1 Assignment
0 Petitions
Accused Products
Abstract
A thread analysis tool records a set of currently-held synchronization objects and currently-acquired objects when a thread acquires one or more objects, then searches for a lock acquisition hierarchy violation that may cause program deadlock. If a violation is found, it is reported to the user. Software to implement the methods of the analysis tool, and systems using the methods, are also described and claimed.
-
Citations
18 Claims
-
1. A method comprising:
-
for a first thread which acquires a synchronization primitive, recording a set of currently-held synchronization primitives and a set of currently-acquired synchronization primitives; indicating a possibly-unsafe lock release when the first thread releases a resource set s of resource set elements r and one or more of the resource set elements r of the resource set s was not among a plurality of resource set elements acquired by the first thread on entry to the synchronization primitive previously acquired by the first thread; constructing a graph of connected nodes, where a node indicates the set of currently-held synchronization primitives and the set of currently-acquired synchronization primitives; searching the graph for a node to indicate the set of currently-held synchronization primitives and the set of currently-acquired synchronization primitives; and searching for a lock acquisition hierarchy violation, in which a second thread acquires a partial acquisition hierarchy of the synchronization primitive previously acquired by the first thread, wherein searching for a lock acquisition hierarchy violation comprises searching for a cycle in the graph; reporting the lock acquisition hierarchy violation; and reporting the possibly-unsafe lock release. - View Dependent Claims (2, 3, 4, 5, 6)
-
-
7. A non-transitory computer-readable medium having instructions stored thereon to cause a programmable machine to perform operations comprising:
-
for a first thread which acquires a synchronization primitive, recording a set of currently-held synchronization primitives and a set of currently-acquired synchronization primitives; indicating a possibly-unsafe lock release when the first thread releases a resource set s of resource set elements r and one or more of the resource set elements r of the resource set s was not among a plurality of resource set elements acquired by the first thread on entry to the synchronization primitive previously acquired by the first thread; constructing a graph of connected nodes, where a node indicates the set of currently-held synchronization primitives and the set of currently-acquired synchronization primitives; searching the graph for a node to indicate the set of currently-held synchronization primitives and the set of currently-acquired synchronization primitives; and searching for a lock acquisition hierarchy violation, in which a second thread acquires a partial acquisition hierarchy of the synchronization primitive previously acquired by the first thread, wherein searching for a lock acquisition hierarchy violation comprises searching for a cycle in the graph; reporting the lock acquisition hierarchy violation; and reporting the possibly-unsafe lock release. - View Dependent Claims (8, 9, 10, 11, 12)
-
-
13. A system comprising:
-
a plurality of processors; a multi-threaded program; data collection logic to collect information about synchronization operations of the program;
analysis logic to examine the information and detect a first thread which acquires a synchronization primitive;reporting logic to record a set of currently-held synchronization primitives and a set of currently-acquired synchronization primitives based on the detected first thread; wherein the analysis logic to further indicate a possibly-unsafe lock release when the first thread releases a resource set s of resource set elements r and one or more of the resource set elements r of the resource set s was not among a plurality of resource set elements acquired by the first thread on entry to the synchronization primitive previously acquired by the first thread; wherein the analysis logic to further construct a graph of connected nodes, where a node indicates the set of currently-held synchronization primitives and the set of currently-acquired synchronization primitives; wherein the analysis logic to further search the graph for a node to indicate the set of currently-held synchronization primitives and the set of currently-acquired synchronization primitives; wherein the analysis logic to further search for a lock acquisition hierarchy violation, in which a second thread acquires a partial acquisition hierarchy of the synchronization primitive previously acquired by the first thread, wherein the search for a lock acquisition hierarchy violation comprises a search for a cycle in the graph; and wherein the reporting logic to further report the lock acquisition hierarchy violation and report the possibly-unsafe lock release. - View Dependent Claims (14, 15, 16, 17, 18)
-
Specification