depends: fix non-atomic reads in capnp debug assertions #36556

pull xyzconstant wants to merge 1 commits into bitcoin:master from xyzconstant:depends-capnp-kj-atomic-reads changing 3 files +174 −1
  1. xyzconstant commented at 12:22 AM on October 17, 2026: contributor

    KJ's debug assertions read the mutex futex word and AtomicRefcounted refcounts non-atomically. The TSan job builds capnp without optimization, which automatically enables these assertions, and TSan reports these reads as data races the moment KJ objects start communicating across threads.

    libmultiprocess enables cross-thread communication for the first time in bitcoin-core/libmultiprocess#376, which replaces the pipe used in EventLoop::sync() with kj::Executor::executeSync(). This is what triggered the failure.

    Patches are the upstream commits capnproto/capnproto@b91a6ba7c7 and capnproto/capnproto@cc13c8c45f, which are backports of the v2 fixes in capnproto/capnproto#2781 and capnproto/capnproto#2843 (backport PR: capnproto/capnproto#2855).

  2. depends: fix non-atomic reads in capnp debug assertions
    KJ's debug assertions read the mutex futex word and `AtomicRefcounted`
    refcounts non-atomically. The TSan job builds capnp without optimization,
    which automatically enables these assertions, and TSan reports these reads
    as data races the moment KJ objects start communicating across threads.
    
    libmultiprocess enables cross-thread communication for the first time
    in https://github.com/bitcoin-core/libmultiprocess/pull/376, which replaces
    the pipe used in `EventLoop::sync()` with `kj::Executor::executeSync()`.
    
    Patches are the upstream commits
    https://github.com/capnproto/capnproto/commit/b91a6ba7c7 and
    https://github.com/capnproto/capnproto/commit/cc13c8c45f, which are backports
    of the v2 fixes in capnproto/capnproto#2781 and capnproto/capnproto#2843
    (https://github.com/capnproto/capnproto/pull/2855).
    6e8e85ddcf
  3. DrahtBot added the label Build system on Oct 17, 2026
  4. DrahtBot commented at 12:22 AM on October 17, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    External sites

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process.

    Type Reviewers
    ACK Sjors, ryanofsky

    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.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  5. fanquake commented at 7:41 AM on October 19, 2026: member
  6. Sjors commented at 8:11 AM on October 21, 2026: member

    ACK 6e8e85ddcf2eb4a062fab3cd2b9c046edfbf72ec

    I verified that the patches match upstream, and that TSan needs both (if we continue with https://github.com/bitcoin-core/libmultiprocess/pull/376).

    If we want capnp's tests to pass under TSan, we'd have to backport several other changes. But given that we set BUILD_TESTING=OFF, I guess it's unnecessary to backport things just to make tests pass? (I did manage locally)

  7. xyzconstant commented at 4:50 PM on October 21, 2026: contributor

    Thanks @Sjors! I'm not sure which exact tests would fail and need backports, but I'd lean toward keeping BUILD_TESTING=OFF as you said, so we don't unnecessarily backport things just to make them work.

  8. in depends/packages/capnp.mk:12 in 6e8e85ddcf
       4 | @@ -5,6 +5,8 @@ $(package)_download_file=$(native_$(package)_download_file)
       5 |  $(package)_file_name=$(native_$(package)_file_name)
       6 |  $(package)_sha256_hash=$(native_$(package)_sha256_hash)
       7 |  $(package)_patches=macos_accept_dead_socket.patch
       8 | +$(package)_patches += kj_atomicaddref_atomic_read.patch
       9 | +$(package)_patches += kj_mutex_atomic_futex_reads.patch
      10 |  
      11 |  define $(package)_set_vars
      12 |    $(package)_config_opts := -DBUILD_TESTING=OFF
    


    ryanofsky commented at 4:53 PM on November 10, 2026:

    re: Sjors #36556 (comment)

    In commit "depends: fix non-atomic reads in capnp debug assertions" (6e8e85ddcf2eb4a062fab3cd2b9c046edfbf72ec)

    given that we set BUILD_TESTING=OFF, I guess it's unnecessary to backport things just to make tests pass?

    Yeah, backporting test-only fixes could add more patches to maintain, so I think current approach is reasonable, though theoretically enabling more test could expose issues worth fixing.

  9. in depends/packages/capnp.mk:9 in 6e8e85ddcf
       4 | @@ -5,6 +5,8 @@ $(package)_download_file=$(native_$(package)_download_file)
       5 |  $(package)_file_name=$(native_$(package)_file_name)
       6 |  $(package)_sha256_hash=$(native_$(package)_sha256_hash)
       7 |  $(package)_patches=macos_accept_dead_socket.patch
       8 | +$(package)_patches += kj_atomicaddref_atomic_read.patch
       9 | +$(package)_patches += kj_mutex_atomic_futex_reads.patch
    


    ryanofsky commented at 4:53 PM on November 10, 2026:

    In commit "depends: fix non-atomic reads in capnp debug assertions" (6e8e85ddcf2eb4a062fab3cd2b9c046edfbf72ec)

    Note: these two patches can be dropped when depends moves to a capnp release that includes capnproto/capnproto#2855, which was merged into capnproto master after v1.5.0.

  10. ryanofsky approved
  11. ryanofsky commented at 5:04 PM on November 10, 2026: contributor

    Code review ACK 6e8e85ddcf2eb4a062fab3cd2b9c046edfbf72ec. Thanks for tracking down the race and getting the fix merged upstream first, which makes the patches easy to check.

    I checked that both patch files are identical to git format-patch output for capnproto/capnproto@b91a6ba7c7 and capnproto/capnproto@cc13c8c45f apart from the git version in the signature line, that these are the two commits capnproto/capnproto#2855 merged

  12. ryanofsky added the label DrahtBot Guix build requested on Nov 10, 2026
  13. fanquake commented at 7:15 PM on November 10, 2026: member

    Guix Build:

    x86_64
    78d2b12264f22ffad4233488251024e45fcf0dd862169f6910ede763e72d6cea  guix-build-6e8e85ddcf2e/output/aarch64-linux-gnu/SHA256SUMS.part
    e8b6a1f99626f0fed3bd4d39022bccf453b9e674c29139edf37d0a9f7e50d383  guix-build-6e8e85ddcf2e/output/aarch64-linux-gnu/bitcoin-6e8e85ddcf2e-aarch64-linux-gnu-debug.tar.gz
    811dee062493dbc03430cea9fd2a3fec991612454ee58553705c2c0586639394  guix-build-6e8e85ddcf2e/output/aarch64-linux-gnu/bitcoin-6e8e85ddcf2e-aarch64-linux-gnu.tar.gz
    b678217265d516327d38d37e5bb9d90326afbdc752264bfbcd6f3f47972c0c28  guix-build-6e8e85ddcf2e/output/arm-linux-gnueabihf/SHA256SUMS.part
    080b0a6eeec060246ac63d610ca20226c60dc391fbc1a5732d495bed6c16faeb  guix-build-6e8e85ddcf2e/output/arm-linux-gnueabihf/bitcoin-6e8e85ddcf2e-arm-linux-gnueabihf-debug.tar.gz
    35ed85b6f223ce5843e83b1389038192584456fedf7fbfb9b4c72ab64c7d4677  guix-build-6e8e85ddcf2e/output/arm-linux-gnueabihf/bitcoin-6e8e85ddcf2e-arm-linux-gnueabihf.tar.gz
    28d9bdeb5517b7355d5ea2344a9c385674c723a726b1ccbb106ddcc18a72fcd6  guix-build-6e8e85ddcf2e/output/arm64-apple-darwin/SHA256SUMS.part
    086804ee4b0a33b3cd9d6f0c2ed7acb59f75f69ebef29f31c84cf27e72efb1a0  guix-build-6e8e85ddcf2e/output/arm64-apple-darwin/bitcoin-6e8e85ddcf2e-arm64-apple-darwin-codesigning.tar.gz
    32d7ab100949fb36fb3a4de2fce6a3dece7a0b9157b3812a0535eba74efaa07f  guix-build-6e8e85ddcf2e/output/arm64-apple-darwin/bitcoin-6e8e85ddcf2e-arm64-apple-darwin-unsigned.tar.gz
    9972fce2f0320680b701f579d2c469268db49c8dca8e45e7576640415e0bfcdb  guix-build-6e8e85ddcf2e/output/arm64-apple-darwin/bitcoin-6e8e85ddcf2e-arm64-apple-darwin-unsigned.zip
    664d1ce9232a57b4c286c055f905355f75f3645067fcd3afda70a10595578fc3  guix-build-6e8e85ddcf2e/output/dist-archive/bitcoin-6e8e85ddcf2e.tar.gz
    0a850f4e5a06c89e63c716c998a40bc9b1e6e1eefdf848120d5b5009f16505df  guix-build-6e8e85ddcf2e/output/powerpc64-linux-gnu/SHA256SUMS.part
    8f38b34b1246890a8bbbe46917090e71270ca378f225e0eea798beb0cca1fa5f  guix-build-6e8e85ddcf2e/output/powerpc64-linux-gnu/bitcoin-6e8e85ddcf2e-powerpc64-linux-gnu-debug.tar.gz
    b7b4cd880afac0800b8f985fef98fb6f099e8f080cf956c79cc5df66033e29df  guix-build-6e8e85ddcf2e/output/powerpc64-linux-gnu/bitcoin-6e8e85ddcf2e-powerpc64-linux-gnu.tar.gz
    0cf15e9779e66dd79620663d695a47edbc1dbb9d2ff1437082dec96b078513f7  guix-build-6e8e85ddcf2e/output/riscv64-linux-gnu/SHA256SUMS.part
    05dbcde3cefc99d1c41b22aea024b455bc6df474db03e338216ff448b1ee7307  guix-build-6e8e85ddcf2e/output/riscv64-linux-gnu/bitcoin-6e8e85ddcf2e-riscv64-linux-gnu-debug.tar.gz
    3db293892177ba9e0703ca234d01f4db416e852a22f369d9d5dc8e010d20437a  guix-build-6e8e85ddcf2e/output/riscv64-linux-gnu/bitcoin-6e8e85ddcf2e-riscv64-linux-gnu.tar.gz
    d2592edfe8cea8a03d6b6057f78309e1b69535347965c7d881fef058da41fbe8  guix-build-6e8e85ddcf2e/output/x86_64-apple-darwin/SHA256SUMS.part
    1d418c7e86bb891b3972a1aa0c9240c9d14cad8257bbad014fd733ceb4598114  guix-build-6e8e85ddcf2e/output/x86_64-apple-darwin/bitcoin-6e8e85ddcf2e-x86_64-apple-darwin-codesigning.tar.gz
    7ffea7050e1bd5f5a7bdfe438def4fb6d300d2268223b26a80ac386bfb2b9383  guix-build-6e8e85ddcf2e/output/x86_64-apple-darwin/bitcoin-6e8e85ddcf2e-x86_64-apple-darwin-unsigned.tar.gz
    0c8956869cbba72e91968d327908f1ae303f91f8365dbceb85e4bc7b0d040d9a  guix-build-6e8e85ddcf2e/output/x86_64-apple-darwin/bitcoin-6e8e85ddcf2e-x86_64-apple-darwin-unsigned.zip
    49aecaef4c807b64d6c60526077b3c1a66a800f45c35521b8bddb0b41509ca37  guix-build-6e8e85ddcf2e/output/x86_64-linux-gnu/SHA256SUMS.part
    cc635b24610bfbcc4fa7625f2e254c68ade52a3948d5de377de13ca5ea7489d1  guix-build-6e8e85ddcf2e/output/x86_64-linux-gnu/bitcoin-6e8e85ddcf2e-x86_64-linux-gnu-debug.tar.gz
    5ba3cd97cd72ea02de0526770fba858af79456995e36a3c9994fc639faae7a36  guix-build-6e8e85ddcf2e/output/x86_64-linux-gnu/bitcoin-6e8e85ddcf2e-x86_64-linux-gnu.tar.gz
    99370974cb7b4f9b3df00eada09f98feb6e732612fe02f303291f9ab355163da  guix-build-6e8e85ddcf2e/output/x86_64-w64-mingw32/SHA256SUMS.part
    78db5eb1364835020a49215deb85e3e6be728075a11d7b56c060cdf335e02a95  guix-build-6e8e85ddcf2e/output/x86_64-w64-mingw32/bitcoin-6e8e85ddcf2e-win64-codesigning.tar.gz
    c204caf6706c62d5de4d5452d0417f80afce12e0064601374dc53c715da40d66  guix-build-6e8e85ddcf2e/output/x86_64-w64-mingw32/bitcoin-6e8e85ddcf2e-win64-debug.zip
    ee508b003c1090e6a02adcf51ef7b2e7f887de485c3340a9669eef0a238734e1  guix-build-6e8e85ddcf2e/output/x86_64-w64-mingw32/bitcoin-6e8e85ddcf2e-win64-setup-unsigned.exe
    729bc8d906275a8f8dc702fe761f85dbf486263e891caae7b75f4118bdc1a464  guix-build-6e8e85ddcf2e/output/x86_64-w64-mingw32/bitcoin-6e8e85ddcf2e-win64-unsigned.zip
    
  14. fanquake merged this on Nov 10, 2026
  15. fanquake closed this on Nov 10, 2026

  16. maflcko removed the label DrahtBot Guix build requested on Nov 10, 2026
  17. Sjors referenced this in commit 22bd7aa745 on Nov 11, 2026
  18. DrahtBot commented at 10:58 PM on November 13, 2026: contributor

    <!--9cd9c72976c961c55c7acef8f6ba82cd-->

    Guix builds (on x86_64) [untrusted test-only build, possibly unsafe, not for production use]

    File commit 229e79321c415051fdb6cd2da7115ebe456fe849<br>(master) commit 40bb0da74269001b8bcca3cbd4f8c5f3e701452e<br>(pull/36556/merge)
    *-aarch64-linux-gnu-debug.tar.gz 3ec4f28bbd242e06... 8df6c3c9f568e26d...
    *-aarch64-linux-gnu.tar.gz 65759403cebedf03... fd4a78afbeab18fb...
    *-arm-linux-gnueabihf-debug.tar.gz 7ad9cdc35373432c... 49afec523c4cfe67...
    *-arm-linux-gnueabihf.tar.gz ca61cbb18adaaf11... 1624c9fcbfad32e2...
    *-arm64-apple-darwin-codesigning.tar.gz 9740298c9f5d42ea... 1c29eeff7353e093...
    *-arm64-apple-darwin-unsigned.tar.gz 353c3ebcef2ac475... 771239ff12556e0c...
    *-arm64-apple-darwin-unsigned.zip 146f0ec490a2b9c3... a716bc2b4a9e576a...
    *-powerpc64-linux-gnu-debug.tar.gz 104896964fee3b82... 35688848a4bffd37...
    *-powerpc64-linux-gnu.tar.gz 73db37793a77b763... 20e64076916a8f20...
    *-riscv64-linux-gnu-debug.tar.gz 4d627f66b4ced378... 6b91d9a201ae3641...
    *-riscv64-linux-gnu.tar.gz 037ebba78e3e04b2... 6f2175d29928ec7c...
    *-win64-codesigning.tar.gz 56a941b52f2b7e23... 28031b4d92fb8483...
    *-win64-debug.zip d71f8a2291303a4b... efac3adf10ea6b65...
    *-win64-setup-unsigned.exe e8704bdf4214e347... 6df92eefa45d3c2d...
    *-win64-unsigned.zip c92856aaae10aaee... a5afb4ea657c2478...
    *-x86_64-apple-darwin-codesigning.tar.gz 8c57a8b8094e5025... b2972d7e39a4f401...
    *-x86_64-apple-darwin-unsigned.tar.gz 03c5e3ea843dba0f... 7c23d7d5b661175c...
    *-x86_64-apple-darwin-unsigned.zip 96458bce03f6cde8... 8fc4bc86158fdd89...
    *-x86_64-linux-gnu-debug.tar.gz c181d39d826b32f5... 83488a8a0e959732...
    *-x86_64-linux-gnu.tar.gz 9913f8c9f4d30c73... 5c49efcbb2ea5115...
    *.tar.gz 1466bdd87f5d7a50... 5b4350f914688ae5...
    SHA256SUMS.part cf268cb2fb27a9ce... 19ad0abb3281e3bb...
    guix_build.log 9e55024fcd2b3b46... 458ca79337b41bc3...
    guix_build.log.diff f71f894b59a805fa...

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-11-16 00:51 UTC

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