HomePhabricator

Prevent UB in DeleteLock() function

Description

Prevent UB in DeleteLock() function

Summary:

  • refactor: Add LockStackItem type alias
  • refactor: Add LockPair type alias
  • refactor: Refactor duplicated code into LockHeld()
  • Replace thread_local g_lockstack with a mutex-protected map

This change prevents UB in case of early g_lockstack destroying.

Co-authored-by: Wladimir J. van der Laan <laanwj@protonmail.com>

  • doc: Add and fix comments about never destroyed objects

This is a backport of Core PR18881

Test Plan:

ninja all check-all

Also in debug mode.

Reviewers: #bitcoin_abc, majcosta

Reviewed By: #bitcoin_abc, majcosta

Subscribers: majcosta

Differential Revision: https://reviews.bitcoinabc.org/D7525

Details

Provenance
Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>Authored on May 5 2020, 05:07
deadalnixCommitted on Sep 22 2020, 19:15
deadalnixPushed on Sep 22 2020, 19:15
Reviewer
Restricted Project
Differential Revision
D7525: Prevent UB in DeleteLock() function
Parents
rABC309ea9405477: Decouple archiving release notes from automated commits pipeline
Branches
Unknown
Tags
Unknown