Resolve guix non-determinism with emplace_back instead of push_back #32930

pull achow101 wants to merge 1 commits into bitcoin:master from achow101:2025-07-debug-guix-nondet changing 1 files +1 −2
  1. achow101 commented at 6:39 am on July 10, 2025: member

    For some reason, building x86_64-w64-mingw32 on x86_64 and aarch64 results in a single instruction difference which can be traced down to prevector.h:174. The ultimate caller of this is the copy constructor for a prevector that ends up being called by std::vector::push_back in walletmodel.cpp:183. By replacing the push_back with an emplace_back, somehow this non-determinism goes away.

    Closes #32923

  2. DrahtBot commented at 6:39 am on July 10, 2025: contributor

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

    Code Coverage & Benchmarks

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

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK l0rinc, Sjors, maflcko

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  3. maflcko commented at 6:44 am on July 10, 2025: member

    lgtm ACK 3add4b365c90c0943f18dd26d4a18c1e2ee5860e

    Haven’t tested a guix build, but the changes lgtm

  4. achow101 commented at 6:44 am on July 10, 2025: member

    x86_64 guix build:

    0$ find guix-build-3add4b365c90/output/ -type f -print0 | env LC_ALL=C sort -z | xargs -r0 sha256sum
    15d3ec518a66bcff88ae4032a352119945ecae1cad0337bdadc84315dd9405a2c  guix-build-3add4b365c90/output/dist-archive/bitcoin-3add4b365c90.tar.gz
    29a317eb639f20191d13df01c11cd71d6da0f2593c9b6048f882ef40e0a080cc1  guix-build-3add4b365c90/output/x86_64-w64-mingw32/SHA256SUMS.part
    3083fb802296373e8d0faa4fdda4ce072f0f95f9443e9ba0682cb5da6dc55d7b6  guix-build-3add4b365c90/output/x86_64-w64-mingw32/bitcoin-3add4b365c90-win64-codesigning.tar.gz
    41aa4834f17fee7b6cb7b5c72878eb6f6b3875d23ab35337c02f92768657fa257  guix-build-3add4b365c90/output/x86_64-w64-mingw32/bitcoin-3add4b365c90-win64-debug.zip
    5663b6fb28095c5c6ba331675c257a0ce3ef7d92f4c04e2ff96a093e030322e88  guix-build-3add4b365c90/output/x86_64-w64-mingw32/bitcoin-3add4b365c90-win64-setup-unsigned.exe
    6ad8ab977a123d56642aef2291a4b9d0d662be9cdbbcc304c079b898e5f37fb33  guix-build-3add4b365c90/output/x86_64-w64-mingw32/bitcoin-3add4b365c90-win64-unsigned.zip
    
  5. Sjors commented at 7:10 am on July 10, 2025: member

    Concept ACK

    I’ll spin up a new aarch64 guix machine to test if this actually makes determinism go away. Even if it doesn’t, the change itself is fine since it removes a line, but you’d have to change the commit message.

    3add4b365c90c0943f18dd26d4a18c1e2ee5860e builds and passes the tests locally for me on Apple Silicon macOS 15.5. Not sure what’s up with CI.

    x86_64 guix hashes:

    05d3ec518a66bcff88ae4032a352119945ecae1cad0337bdadc84315dd9405a2c  guix-build-3add4b365c90/output/dist-archive/bitcoin-3add4b365c90.tar.gz
    19a317eb639f20191d13df01c11cd71d6da0f2593c9b6048f882ef40e0a080cc1  guix-build-3add4b365c90/output/x86_64-w64-mingw32/SHA256SUMS.part
    2083fb802296373e8d0faa4fdda4ce072f0f95f9443e9ba0682cb5da6dc55d7b6  guix-build-3add4b365c90/output/x86_64-w64-mingw32/bitcoin-3add4b365c90-win64-codesigning.tar.gz
    31aa4834f17fee7b6cb7b5c72878eb6f6b3875d23ab35337c02f92768657fa257  guix-build-3add4b365c90/output/x86_64-w64-mingw32/bitcoin-3add4b365c90-win64-debug.zip
    4663b6fb28095c5c6ba331675c257a0ce3ef7d92f4c04e2ff96a093e030322e88  guix-build-3add4b365c90/output/x86_64-w64-mingw32/bitcoin-3add4b365c90-win64-setup-unsigned.exe
    5ad8ab977a123d56642aef2291a4b9d0d662be9cdbbcc304c079b898e5f37fb33  guix-build-3add4b365c90/output/x86_64-w64-mingw32/bitcoin-3add4b365c90-win64-unsigned.zip
    
  6. maflcko commented at 7:21 am on July 10, 2025: member
    Congrats, you are triggering another compiler bug. See 9999dbc1bd171931f02266d7c1a5cfd39f49238e for more details.
  7. in src/qt/walletmodel.cpp:182 in 3add4b365c outdated
    178@@ -179,8 +179,7 @@ WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransact
    179             setAddress.insert(rcp.address);
    180             ++nAddresses;
    181 
    182-            CRecipient recipient{DecodeDestination(rcp.address.toStdString()), rcp.amount, rcp.fSubtractFeeFromAmount};
    183-            vecSend.push_back(recipient);
    184+            vecSend.emplace_back(DecodeDestination(rcp.address.toStdString()), rcp.amount, rcp.fSubtractFeeFromAmount);
    


    maflcko commented at 7:24 am on July 10, 2025:
    0            vecSend.emplace_back(CRecipient {DecodeDestination(rcp.address.toStdString()), rcp.amount, rcp.fSubtractFeeFromAmount});
    

    I don’t have an apple, but I guess this may be the patch to work around the xcode compiler bug. I don’t know if that still works around the non-determinism.

    As a completely different alternative, you could also try #32597 (review) to remove the std::string construction from the header file and maybe take some load off of the optimize passes or linker?

  8. DrahtBot added the label CI failed on Jul 10, 2025
  9. Resolve guix non-determinism with emplace_back instead of push_back
    For some reason, building x86_64-w64-mingw32 on x86_64 and aarch64
    results in a single instruction difference which can be traced down to
    prevector.h:174. The ultimate caller of this is the copy constructor for
    a prevector that ends up being called by std::vector::push_back in
    walletmodel.cpp:183. By replacing the push_back with an emplace_back,
    somehow this non-determinism goes away.
    f43571010e
  10. achow101 force-pushed on Jul 10, 2025
  11. achow101 commented at 8:11 pm on July 10, 2025: member

    guix builds of f43571010e38

    x86_64

    0$ find guix-build-f43571010e38/output/ -type f -print0 | env LC_ALL=C sort -z | xargs -r0 sha256sum
    1bb9e6435df82cfe01c78e046ef39cea62a3b0ad0deafa66e1d2a15257bc21eeb  guix-build-f43571010e38/output/dist-archive/bitcoin-f43571010e38.tar.gz
    27d3bc9459a51abcb2d9d36b69fc135cbb4940c092a9f8df63032c6e9f659a958  guix-build-f43571010e38/output/x86_64-w64-mingw32/SHA256SUMS.part
    334af63c893a315745364d1f4dd36bbc1521eef0cad42ea964ba1d0dc5cbcf738  guix-build-f43571010e38/output/x86_64-w64-mingw32/bitcoin-f43571010e38-win64-codesigning.tar.gz
    420929256891cacbeb58f75644257631273c4096597a9e4e366c61807ce87eade  guix-build-f43571010e38/output/x86_64-w64-mingw32/bitcoin-f43571010e38-win64-debug.zip
    58d39a4e45bc66dad9c9becd16ab11a77abc976a0091d370b26977d5194ed9535  guix-build-f43571010e38/output/x86_64-w64-mingw32/bitcoin-f43571010e38-win64-setup-unsigned.exe
    6969f416e0004ecba38e4dbec9bb60e0d5c07f21aae6d72f49480bb85426725ab  guix-build-f43571010e38/output/x86_64-w64-mingw32/bitcoin-f43571010e38-win64-unsigned.zip
    

    aarch64

    0bb9e6435df82cfe01c78e046ef39cea62a3b0ad0deafa66e1d2a15257bc21eeb  guix-build-f43571010e38/output/dist-archive/bitcoin-f43571010e38.tar.gz
    17d3bc9459a51abcb2d9d36b69fc135cbb4940c092a9f8df63032c6e9f659a958  guix-build-f43571010e38/output/x86_64-w64-mingw32/SHA256SUMS.part
    234af63c893a315745364d1f4dd36bbc1521eef0cad42ea964ba1d0dc5cbcf738  guix-build-f43571010e38/output/x86_64-w64-mingw32/bitcoin-f43571010e38-win64-codesigning.tar.gz
    320929256891cacbeb58f75644257631273c4096597a9e4e366c61807ce87eade  guix-build-f43571010e38/output/x86_64-w64-mingw32/bitcoin-f43571010e38-win64-debug.zip
    48d39a4e45bc66dad9c9becd16ab11a77abc976a0091d370b26977d5194ed9535  guix-build-f43571010e38/output/x86_64-w64-mingw32/bitcoin-f43571010e38-win64-setup-unsigned.exe
    5969f416e0004ecba38e4dbec9bb60e0d5c07f21aae6d72f49480bb85426725ab  guix-build-f43571010e38/output/x86_64-w64-mingw32/bitcoin-f43571010e38-win64-unsigned.zip
    
  12. in src/qt/walletmodel.cpp:182 in f43571010e
    178@@ -179,8 +179,7 @@ WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransact
    179             setAddress.insert(rcp.address);
    180             ++nAddresses;
    181 
    182-            CRecipient recipient{DecodeDestination(rcp.address.toStdString()), rcp.amount, rcp.fSubtractFeeFromAmount};
    183-            vecSend.push_back(recipient);
    184+            vecSend.emplace_back(CRecipient{DecodeDestination(rcp.address.toStdString()), rcp.amount, rcp.fSubtractFeeFromAmount});
    


    l0rinc commented at 8:22 pm on July 10, 2025:

    do we need to create a temp copy or would this also work?

    0            vecSend.emplace_back(DecodeDestination(rcp.address.toStdString()), rcp.amount, rcp.fSubtractFeeFromAmount);
    

    achow101 commented at 8:24 pm on July 10, 2025:

    l0rinc commented at 8:24 pm on July 10, 2025:
    Ah, it was already the case before, my bad
  13. l0rinc commented at 8:25 pm on July 10, 2025: contributor
    code review ACK f43571010e3853e83a21aa4774b1c8da47b5d961
  14. DrahtBot requested review from maflcko on Jul 10, 2025
  15. DrahtBot requested review from Sjors on Jul 10, 2025
  16. DrahtBot removed the label CI failed on Jul 10, 2025
  17. Sjors commented at 7:31 am on July 11, 2025: member

    utACK f43571010e3853e83a21aa4774b1c8da47b5d961

    x86_64 guix hashes:

    0bb9e6435df82cfe01c78e046ef39cea62a3b0ad0deafa66e1d2a15257bc21eeb  guix-build-f43571010e38/output/dist-archive/bitcoin-f43571010e38.tar.gz
    17d3bc9459a51abcb2d9d36b69fc135cbb4940c092a9f8df63032c6e9f659a958  guix-build-f43571010e38/output/x86_64-w64-mingw32/SHA256SUMS.part
    234af63c893a315745364d1f4dd36bbc1521eef0cad42ea964ba1d0dc5cbcf738  guix-build-f43571010e38/output/x86_64-w64-mingw32/bitcoin-f43571010e38-win64-codesigning.tar.gz
    320929256891cacbeb58f75644257631273c4096597a9e4e366c61807ce87eade  guix-build-f43571010e38/output/x86_64-w64-mingw32/bitcoin-f43571010e38-win64-debug.zip
    48d39a4e45bc66dad9c9becd16ab11a77abc976a0091d370b26977d5194ed9535  guix-build-f43571010e38/output/x86_64-w64-mingw32/bitcoin-f43571010e38-win64-setup-unsigned.exe
    5969f416e0004ecba38e4dbec9bb60e0d5c07f21aae6d72f49480bb85426725ab  guix-build-f43571010e38/output/x86_64-w64-mingw32/bitcoin-f43571010e38-win64-unsigned.zip
    

    Unfortunately I still can’t get my aarch64 guix setup to work (see #32759), so I can’t test myself if this fixes the indeterminism. But at least it does on your machine.

  18. maflcko commented at 8:18 am on July 11, 2025: member

    lgtm ACK f43571010e3853e83a21aa4774b1c8da47b5d961

    Haven’t done a guix build, because my riscv64 machine died. I’ll try to set it up fresh again next week, or so.

  19. fanquake commented at 9:19 am on July 11, 2025: member

    Guix Build (aarch64):

     0b75d75ed9b64aadadcccce97bf1fcafa2802c916f4a12befe7fef3260f2d5bb7  guix-build-f43571010e38/output/aarch64-linux-gnu/SHA256SUMS.part
     1a9cdcb840b05cad7c69dafb13003ff2e051ab162e30a8959af011f76c5abe576  guix-build-f43571010e38/output/aarch64-linux-gnu/bitcoin-f43571010e38-aarch64-linux-gnu-debug.tar.gz
     27269ff5420cd864c351fc075c0cd8b57c9f73264dd5083eabeddf5f673a88263  guix-build-f43571010e38/output/aarch64-linux-gnu/bitcoin-f43571010e38-aarch64-linux-gnu.tar.gz
     38c169b4d4746983856a55a6195741a7468cea2a225e6f6d9d53901a3048093a2  guix-build-f43571010e38/output/arm-linux-gnueabihf/SHA256SUMS.part
     45f288115356d8baec2c5d76c90719c11cdf8ef5fcb8dd7f539c09be256fbaf28  guix-build-f43571010e38/output/arm-linux-gnueabihf/bitcoin-f43571010e38-arm-linux-gnueabihf-debug.tar.gz
     5b570bef77ee3cd3824fc0457d10672613eeca1e9baedcb54976a557681d159b4  guix-build-f43571010e38/output/arm-linux-gnueabihf/bitcoin-f43571010e38-arm-linux-gnueabihf.tar.gz
     6ea1fb792183c0fc396f6ea26ecc7c3815c8124aed7af1e4d52fd8c83f54d8de1  guix-build-f43571010e38/output/arm64-apple-darwin/SHA256SUMS.part
     78e5d105ec5e7923a4e057fbd6aad80e7cfb609810b5704b1962621a4a7fc960a  guix-build-f43571010e38/output/arm64-apple-darwin/bitcoin-f43571010e38-arm64-apple-darwin-codesigning.tar.gz
     8afef674fd88b5e4763fc29aed821507e4dbb8c61b228bbf2259351a9613fca5a  guix-build-f43571010e38/output/arm64-apple-darwin/bitcoin-f43571010e38-arm64-apple-darwin-unsigned.tar.gz
     99039a1c71c06726dc498b7ba7431b9717ee88f8a183ec83a38a48a266ed1a22f  guix-build-f43571010e38/output/arm64-apple-darwin/bitcoin-f43571010e38-arm64-apple-darwin-unsigned.zip
    10bb9e6435df82cfe01c78e046ef39cea62a3b0ad0deafa66e1d2a15257bc21eeb  guix-build-f43571010e38/output/dist-archive/bitcoin-f43571010e38.tar.gz
    11f44fdd78ae91a7950951ea407d372265598e95f9e2a092a2522f79c46677716c  guix-build-f43571010e38/output/powerpc64-linux-gnu/SHA256SUMS.part
    127823af2b8534e47c8db6d9760db2a5cde93cbafe51f88cf814f661de9ecd2b3c  guix-build-f43571010e38/output/powerpc64-linux-gnu/bitcoin-f43571010e38-powerpc64-linux-gnu-debug.tar.gz
    136b6fbd238f89d5606b1dc3e72dc07e489e3dfe20db5f7487a616bd214a355845  guix-build-f43571010e38/output/powerpc64-linux-gnu/bitcoin-f43571010e38-powerpc64-linux-gnu.tar.gz
    145ada35a6e0362c73e22680186d6ad6dfcedd410ded0aee682009a8738236a253  guix-build-f43571010e38/output/riscv64-linux-gnu/SHA256SUMS.part
    15b2d7c18d321a1e3039ee80d80dff491e619c63d7681b492600ddf41cb17175a5  guix-build-f43571010e38/output/riscv64-linux-gnu/bitcoin-f43571010e38-riscv64-linux-gnu-debug.tar.gz
    16a661cf4096aab452ca786897ab4a16c165b169549323fa763e846c40b0e672eb  guix-build-f43571010e38/output/riscv64-linux-gnu/bitcoin-f43571010e38-riscv64-linux-gnu.tar.gz
    171614b5c12cfebdf535947d6559c76e5169b35df2de81433804d5948b5295eeb8  guix-build-f43571010e38/output/x86_64-apple-darwin/SHA256SUMS.part
    1881c906f7644d6c8198c72751334a3558c9c280b15620e10be29542d4b36306f6  guix-build-f43571010e38/output/x86_64-apple-darwin/bitcoin-f43571010e38-x86_64-apple-darwin-codesigning.tar.gz
    199c65f26e10f4d757c0f7c5458a9c187ff3bfc92d66b8690df7f9a206ab93f04c  guix-build-f43571010e38/output/x86_64-apple-darwin/bitcoin-f43571010e38-x86_64-apple-darwin-unsigned.tar.gz
    206ede84df539ca0e3d01bf8324b6c0bb7d2dddf5a32e91300883b81bb7828aeb3  guix-build-f43571010e38/output/x86_64-apple-darwin/bitcoin-f43571010e38-x86_64-apple-darwin-unsigned.zip
    21cf8182af8af7138da6ccbe93c4ecec2d5659e063fc89392f6c2f98fdadd29190  guix-build-f43571010e38/output/x86_64-linux-gnu/SHA256SUMS.part
    222702a08aa94e429f37311b2a817e9a8460b225175ab59aef12df62dc3bbc1cc0  guix-build-f43571010e38/output/x86_64-linux-gnu/bitcoin-f43571010e38-x86_64-linux-gnu-debug.tar.gz
    23247b9cc88058a04888e7f83581d48a02b450a4f25ea8a7e706bea03c8a808f48  guix-build-f43571010e38/output/x86_64-linux-gnu/bitcoin-f43571010e38-x86_64-linux-gnu.tar.gz
    247d3bc9459a51abcb2d9d36b69fc135cbb4940c092a9f8df63032c6e9f659a958  guix-build-f43571010e38/output/x86_64-w64-mingw32/SHA256SUMS.part
    2534af63c893a315745364d1f4dd36bbc1521eef0cad42ea964ba1d0dc5cbcf738  guix-build-f43571010e38/output/x86_64-w64-mingw32/bitcoin-f43571010e38-win64-codesigning.tar.gz
    2620929256891cacbeb58f75644257631273c4096597a9e4e366c61807ce87eade  guix-build-f43571010e38/output/x86_64-w64-mingw32/bitcoin-f43571010e38-win64-debug.zip
    278d39a4e45bc66dad9c9becd16ab11a77abc976a0091d370b26977d5194ed9535  guix-build-f43571010e38/output/x86_64-w64-mingw32/bitcoin-f43571010e38-win64-setup-unsigned.exe
    28969f416e0004ecba38e4dbec9bb60e0d5c07f21aae6d72f49480bb85426725ab  guix-build-f43571010e38/output/x86_64-w64-mingw32/bitcoin-f43571010e38-win64-unsigned.zip
    
  20. fanquake merged this on Jul 11, 2025
  21. fanquake closed this on Jul 11, 2025


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: 2025-08-02 00:13 UTC

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