diff options
author | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2020-06-22 21:12:14 +0300 |
---|---|---|
committer | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2020-08-02 16:42:33 +0300 |
commit | 1f96be25b020a56afa330286ee4f241aa14d3983 (patch) | |
tree | 86f902b36990e429986069d31a2c6164ff615f34 /src/sync.cpp | |
parent | a78742830aa35bf57bcb0a4730977a1e5a1876bc (diff) |
Preserve initial state if push_lock() throws exception
Diffstat (limited to 'src/sync.cpp')
-rw-r--r-- | src/sync.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/sync.cpp b/src/sync.cpp index 10f0483189..f72436530e 100644 --- a/src/sync.cpp +++ b/src/sync.cpp @@ -149,12 +149,17 @@ static void push_lock(void* c, const CLockLocation& locklocation) const LockPair p1 = std::make_pair(i.first, c); if (lockdata.lockorders.count(p1)) continue; - lockdata.lockorders.emplace(p1, lock_stack); const LockPair p2 = std::make_pair(c, i.first); + if (lockdata.lockorders.count(p2)) { + auto lock_stack_copy = lock_stack; + lock_stack.pop_back(); + potential_deadlock_detected(p1, lockdata.lockorders[p2], lock_stack_copy); + // potential_deadlock_detected() does not return. + } + + lockdata.lockorders.emplace(p1, lock_stack); lockdata.invlockorders.insert(p2); - if (lockdata.lockorders.count(p2)) - potential_deadlock_detected(p1, lockdata.lockorders[p2], lockdata.lockorders[p1]); } } |