fuzz: use ImmediateBackgroundTaskRunner to silence DEBUG_LOCKORDER #35284

pull Crypt-iQ wants to merge 1 commits into bitcoin:master from Crypt-iQ:05122026/imm_bg_std_thread changing 1 files +13 −0
  1. Crypt-iQ commented at 4:04 PM on May 13, 2026: contributor

    DEBUG_LOCKORDER was reporting a false positive deadlock with the cmpctblock fuzz harness when using ImmediateTaskRunner. Since it is single-threaded, ImmediateTaskRunner callbacks added LockOrders that could never happen outside of a fuzz test.

    First a block would get connected:

    • LOCK(mempool.cs)
    • BlockConnected (fuzz test runs in same thread)
    • LOCK(m_tx_download_mutex)

    Then a later iteration of the LIMITED_WHILE would send a TX:

    • LOCK(m_tx_download_mutex)
    • LOCK(mempool.cs)

    causing a false positive deadlock. Normally, the BlockConnected callback would run in a different thread and no deadlock is reported.

    Fix this by launching a thread that runs the callback and is immediately joined. I compared this PR to another branch (https://github.com/Crypt-iQ/bitcoin/commit/0028847c6b8b937031228e9a1fce83982976d86e) that uses a ThreadPool and found this PR to be more stable and ~4% quicker.

  2. fuzz: use ImmediateBackgroundTaskRunner to silence DEBUG_LOCKORDER
    DEBUG_LOCKORDER was reporting a false positive deadlock with the
    cmpctblock fuzz harness when using ImmediateTaskRunner. Since it is
    single-threaded, ImmediateTaskRunner callbacks added LockOrders that
    could never happen outside of a fuzz test.
    
    First a block would get connected:
    * LOCK(mempool.cs)
    * BlockConnected (fuzz test runs in same thread)
    * LOCK(m_tx_download_mutex)
    
    Then a later iteration of the LIMITED_WHILE would send a TX:
    * LOCK(m_tx_download_mutex)
    * LOCK(mempool.cs)
    
    causing a false positive deadlock. Normally, the BlockConnected
    callback would run in a different thread and no deadlock is reported.
    
    Fix this by launching a thread that runs the callback and is
    immediately joined.
    801d36f55b
  3. DrahtBot added the label Fuzzing on May 13, 2026
  4. DrahtBot commented at 4:05 PM on May 13, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/35284.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK maflcko, sedited

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #33966 (refactor: disentangle miner startup defaults from runtime options by Sjors)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  5. Crypt-iQ commented at 4:06 PM on May 13, 2026: contributor

    Leaving as draft while I run this to verify there are no timeouts over extended periods of time and/or with multiple cores.

    cc @maflcko, let me know if you want co-author as these are mostly your suggestions.

  6. maflcko commented at 4:22 PM on May 13, 2026: member

    lgtm ACK 801d36f55b6d421f26d2376327699a04bd22e602

    (fwiw)

  7. Crypt-iQ marked this as ready for review on May 14, 2026
  8. Crypt-iQ commented at 11:26 AM on May 14, 2026: contributor

    Leaving as draft while I run this to verify there are no timeouts over extended periods of time and/or with multiple cores.

    Ran for about 16 hours on 20 cores and no crashes / timeouts, so took out of draft

  9. sedited approved
  10. sedited commented at 12:12 PM on May 14, 2026: contributor

    ACK 801d36f55b6d421f26d2376327699a04bd22e602

  11. sedited merged this on May 14, 2026
  12. sedited closed this on May 14, 2026

  13. rustaceanrob referenced this in commit a4ca01c5dc on May 14, 2026
  14. maflcko commented at 2:04 PM on May 15, 2026: member

    Fix this by launching a thread that runs the callback and is immediately joined. I compared this PR to another branch (Crypt-iQ@0028847) that uses a ThreadPool and found this PR to be more stable and ~4% quicker.

    Just to clarify: You tested with AFL? Because when I use libFuzzer, the pool one is faster 20%-40% (depending on whether sanitizers are enabled or not)

  15. Crypt-iQ commented at 2:20 PM on May 15, 2026: contributor

    Just to clarify: You tested with AFL? Because when I use libFuzzer, the pool one is faster 20%-40% (depending on whether sanitizers are enabled or not)

    Yeah, I tested with AFL on Debian without sanitizers


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: 2026-05-19 11:51 UTC

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