mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 10:08:38 +00:00
test: Add case for libstdc++ bug on Windows #36620
No reviewers
Labels
No labels
Android
Backport
Block storage
Brainstorming
Bug
Build system
CI failed
Consensus
Data corruption
Descriptors
Docs
DrahtBot Guix build requested
Feature
Fuzzing
GUI
Good First Review
IPC
Insufficient Review
Kernel
Linux/Unix
Mempool
Mining
Needs Backport (31.x)
Needs Backport (32.x)
Needs Benchmark
Needs Conceptual Review
Needs backport (30.x)
Needs rebase
Needs release note
Net
P2P
PSBT
Privacy
Private Broadcast
Questions and Help
RPC/REST/ZMQ
Refactoring
Resource usage
Review club
Scripts and tools
Settings
TX fees and policy
Tests
Tracking Issue
UTXO Db and Indexes
Up for grabs
Upstream
Utils/log/libs
Validation
Waiting for author
Wallet
Windows
good first issue
interfaces
macOS
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin/bitcoin!36620
Loading…
Reference in a new issue
No description provided.
Delete branch "261023-win-libstdcxx"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The code in
BerkeleyRODatabase::Backup()relies oncopy_file()withoverwrite_existingworking.Upstream fixes:
github.com/gcc-mirror/gcc@017e3f89b0github.com/gcc-mirror/gcc@35c98149a5github.com/gcc-mirror/gcc@8b3e47b409Suggested in https://github.com/bitcoin/bitcoin/pull/36271#issuecomment-5794127014.
Here is an example of the failure when cross-compiling for Windows using GCC 14.2.0:
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
External sites
Reviews
See the guideline and AI policy for information on the review process.
A summary of reviews will appear here.
Conflicts
Reviewers, this pull request conflicts with the following ones:
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.
This can be done, for instance, with the following patch:
Design and approach
The PR says Backup() relies on overwrite_existing but does not say which builds are affected or what happens at runtime. The answer is narrow: a migration retried within the same second stops safely. The test only reports the problem in CI and in developer test runs. If the goal is a CI guard that keeps the project's own Windows toolchain from shipping this bug, say so in the commit message. If the goal is to protect users of affected builds, the fix belongs in the migration code, not in a test. Checked against the checkout. BerkeleyRODatabase::Backup() calls copy_file with overwrite_existing (migrate.cpp:745). Its only caller is migration, because BERKELEY_RO databases can only be opened there (walletdb.cpp:1437-1442). The destination name is
<prefix>_<GetTime()>.legacy.bak(wallet.cpp:4279), and the code comment says this name is meant to be unique (wallet.cpp:4267). If copy_file fails, Backup returns false and migration stops with "Unable to make a backup of your wallet" before the wallet is unlocked or converted (wallet.cpp:4281-4283). The destination already exists only when a backup with the same name was made in the same second. One way this happens is an immediate retry after a failed migration: RestoreWallet copies the backup with copy_options::none and leaves it in place (wallet.cpp:459). The test is correct. Each test case gets its own data directory, it writes two distinct files, and it reads back the result. It also runs in the Windows-native CI job (ci.yml:391-392), so it can guard the project's own toolchain. But it changes nothing at runtime for affected builds. The PR's only repro needed a manual override of the pinned toolchain, and the PR never says which builds are at risk or what users would see. That is a real gap in the stated motivation, so the needs_motivation objection is supported and actionable. The candidate's 'avoid overwrite_existing' option moved to the top-level alternatives with an extra cost found in the checkout. The candidate's goal, baseline and benefit were tightened to match the source. 1 2 3 4Review coverage was incomplete.
Reviewed:
37c2ad655bc2· Full review report · Previous reportspermalink
Could address the Ralph comment?
Can you elaborate on the motivation here? Why this bug specifically? Which users (compiling in what currently used environments) do we expect to hit this?
Even after #36042, users can hit this bug in a build environment we don’t control (e.g. a distro’s
g++-mingw-w64-ucrt64package) that formally meets our minimum requirements but ships an affected libstdc++.Seems harmless to add the test. An alternative could be to reject g++-mingw less than 14.3 during configure?
Done.
Thanks:
It's not clear that adding a test here is that useful, unless you expect cross-compiling end-users are running the unit test binary on their systems before running bitcoind? Otherwise, as mentioned above, maybe it'd be better to reject the compiler outright.
It's also not clear what runtime failure / bug the user would be prevented from hitting (by seeing this test failure) if they happened to be using a broken compiler. If I understand correctly, does this mean that migration has likely never worked on windows with GCC-based cross-compiled binaries, but also nobody has ever reported it?
There are lots of compiler bugs, and we don't add tests for many of them, and the PR description / commit messages here don't really justify the changes, or explain how a user would be affected by this at runtime, if they used a broken compiler.
One other point here is that we have been shipping Windows release binaries (
28.0with12.4.0&29.0/30.0with13.3.0), which should have this bug.30.0is still supported, so if this is serious enough to warrant a unit test now, shouldn't we be patching the compiler/libstdc++ in Guix and doing a point release with the fix?I have to admit that I can’t see a real-life scenario in which the bug affects users.
The code is reachable only when migrating a legacy BDB wallet, either via the
migratewalletRPC command or via the GUI.The
destargument ofBerkeleyRODatabase::Backup()is constructed inMigrateLegacyToDescriptor()and includes a timestamp. If a migration attempt fails for any reason, the next attempt is very likely to write a differently named file. However, the bug can only be hit if the backup file has the same name.It seems to me this is either:
copy_optionsparam fromcopy_fileso that we can't hit this anywhere else.Either way, adding a test that fails where we expect it to fail doesn't seem very helpful to me.
@achow101
Could we?
It seems like a bugfix, because migration shouldn't overwrite?
What's the status here? Looks like there's not agreement to add the test, and no interest in fixing the release binaries, so maybe a new pull can be opened for a wallet refactor? Or something can be done following #34193?