Double lock detected in Warnings::GetMessages() #30400

issue achow101 openend this issue on July 5, 2024
  1. achow101 commented at 11:29 pm on July 5, 2024: member

    Is there an existing issue for this?

    • I have searched the existing issues

    Current behaviour

    Running bitcoin-qt -testnet results in it eventually deadlocking due to a double lock in the warnings code.

    Expected behaviour

    Should not double lock.

    Steps to reproduce

    1. Build with --enable-debug (or define DEBUG_LOCKORDER
    2. Run bitcoin-qt -testnet, and either sync or reindex
    3. It will assert and crash on its own (without DEBUG_LOCKORDER, it will eventually hang)

    Relevant log output

    02024-07-05T23:22:12.212000Z [scheduler] [../../../src/qt/bitcoin.cpp:215] [DebugMessageHandler] [qt] GUI: ClientModel: NotifyAlertChanged
    12024-07-05T23:22:12.212029Z [scheduler] [../../../src/sync.cpp:129] [double_lock_detected] DOUBLE LOCK DETECTED
    22024-07-05T23:22:12.212052Z [scheduler] [../../../src/sync.cpp:130] [double_lock_detected] Lock order:
    32024-07-05T23:22:12.212072Z [scheduler] [../../../src/sync.cpp:136] [double_lock_detected]  (*) 'm_mutex' in ../../../src/node/warnings.cpp:31 (in thread 'scheduler')
    42024-07-05T23:22:12.212092Z [scheduler] [../../../src/sync.cpp:136] [double_lock_detected]  (*) 'm_mutex' in ../../../src/node/warnings.cpp:46 (in thread 'scheduler')
    5Assertion failed: detected double lock for 'm_mutex' in ../../../src/node/warnings.cpp:46 (in thread 'scheduler'), details in debug log.
    

    How did you obtain Bitcoin Core

    Compiled from source

    What version of Bitcoin Core are you using?

    bd5d1688b4311e21c0e0ff89a3ae02ef7d0543b8

    Operating system and version

    Arch

    Machine specifications

    No response

  2. achow101 commented at 11:29 pm on July 5, 2024: member
    cc @stickies-v as you were the last to touch the warnings code.
  3. achow101 added this to the milestone 28.0 on Jul 5, 2024
  4. stickies-v commented at 11:00 am on July 8, 2024: contributor

    Thanks a lot for finding this @achow101

    The bug was introduced in 9c4b0b7ce459765fa1a63b410c3423b90f0d2a5f and affects all bitcoin-qt instances on either whenever a new warning is set. If bitcoin-qt was compiled with --enable-debug it will lead to a crash, otherwise it will lead to the scheduler thread being deadlocked and effectively halting the node. bitcoind is not affected by this bug as far as I can see.

    Another way to reproduce the bug quickly (on any net) is to:

    1. manually shift your system clock forward by > 10 minutes, e.g. 60 minutes to avoid noise
    2. start bitcoin-qt
    3. when the 5th peer connects, bitcoin-qt will hang or crash, depending on whether it was compiled with --enable-debug
  5. glozow closed this on Jul 8, 2024


achow101 stickies-v

Milestone
28.0


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-22 06:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me