#36620 test: Add case for libstdc++ bug on Windows
| Reviewability | Reviews | Agreement | Size | ||||
|---|---|---|---|---|---|---|---|
| #36620 test: Add case for libstdc++ bug on Windows | Ready | 0 | Positive | 0 + 26 tests | |||
|
|
|
|
| |||
Reviewability: ReadyStalePaused Agreement: StrongPositivePositive w/ caveatsNeutralMildDisputedBlockedCrickets Reviews: current code-review ACKs, then (+stale ACKs) and -NACKs; greener = more ACKs. Size: lines added or modified outside tests, then in tests; greener = smaller. | |||||||
Goal
Adds a unit test in `fs_tests` verifying that `fs::copy_file` with `copy_options::overwrite_existing` succeeds. The test exercises a specific upstream libstdc++ bug on Windows where the call fails with a `File exists` error.
Problem: Wallet migration code (`BerkeleyRODatabase::Backup()`) relies on `fs::copy_file` successfully overwriting an existing file. In certain GCC toolchains targeting Windows (GCC 12.x, GCC < 13.4, and GCC < 14.3), libstdc++ fails with `filesystem error: cannot copy file: File exists`, but unit tests lacked coverage to detect this toolchain bug.
Evidence of importance:
- Commit message cites upstream GCC patches fixing the bug (017e3f89b081, 35c98149a5c7, 8b3e47b4099f).
- PR description links to a CI failure demonstrating the test failing under GCC 14.2.0 cross-compilation for Windows: `std::filesystem::__cxx11::filesystem_error: filesystem error: cannot copy file: File exists`.
- PR description points directly to `BerkeleyRODatabase::Backup()` in `src/wallet/migrate.cpp` as relying on this behavior.
Risk of a mistake: low (tests). Touches only unit tests in fs_tests; a failure only affects test execution on buggy toolchains.
Changed since the previous assessment: No functional changes to the patch; the previously missing diff is now provided.
Reviewability
Ready
Nothing known that would invalidate a review now.
Waiting on (from the thread read):
- author: response to maflcko and theuni regarding alternative approaches such as fixing migration not to overwrite 2026-10-26
Agreement
Positive
support without stated reasons, no open objection (maflcko)
Thread notes: Added maflcko's suggestion in c:6420696121 that migration shouldn't overwrite, which also contributes to the discussion started in c:6371922580.
Objections, suggestions, and questions:
| Reviewer | Type | Harm, request, or question | Status | Must be | Author replied | Quote |
|---|---|---|---|---|---|---|
| maflcko (member) | suggestion, style | address Ralph's comment from the previous PR | fixed · fix pushed · author confirmed addressed | answered | yes | 2026-10-23: 'Could address the Ralph comment?' Status from: 2026-10-23: hebasto: 'Done.' |
| fanquake (member) | question, usefulness | why this bug specifically and which users in what environments are expected to hit this | answered · author noted users in uncontrolled build environments meeting minimum requirements could hit it | answered | yes | 2026-10-23: '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?' Status from: 2026-10-23: hebasto: 'Even after #36042, users can hit this bug in a build environment we don’t control' |
| maflcko (member) | suggestion, approach | reject g++-mingw versions less than 14.3 during configure instead of adding the test | open | answered | no | 2026-10-23: 'An alternative could be to reject g++-mingw less than 14.3 during configure?' |
| fanquake (member) | suggestion, usefulness | explain the utility of adding a test for a compiler bug given end-users rarely run tests or hit runtime issues | answered · author conceded there is no known real-life scenario where users would hit the bug | answered | yes | 2026-10-23: '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?' Status from: 2026-10-23: hebasto: 'I have to admit that I can’t see a real-life scenario in which the bug affects users.' |
| theuni (member) | suggestion, usefulness | pursue alternatives such as blocking the compiler or removing copy_options rather than adding a test that fails where expected | open · author deferred by asking achow101 if removing copy_options is viable | answered | yes | 2026-10-23: 'Either way, adding a test that fails where we expect it to fail doesn't seem very helpful to me.' |
| fanquake (member) | question, scope | whether libstdc++ should be patched in Guix and backported to point releases if the issue is serious enough for a unit test | answered · author explained that real-world impact is practically nonexistent | answered | yes | 2026-10-23: '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?' Status from: 2026-10-23: hebasto: 'I have to admit that I can’t see a real-life scenario in which the bug affects users.' |
| maflcko (member) | suggestion, approach | fix migration not to overwrite existing files instead of relying on copy_file with overwrite_existing | open | answered | no | 2026-10-26: 'It seems like a bugfix, because migration shouldn't overwrite?' |
Support:
- maflcko (member) (2026-10-23): Seems harmless to add the test. [not substantive]
Participants:
- fanquake (member, question, 3 statements 2026-10-23 to 2026-10-23): questioned the motivation, runtime impact, and usefulness of adding a test for a compiler bug
- maflcko (member, support, 3 statements 2026-10-23 to 2026-10-26): noted adding the test seems harmless, suggested rejecting affected compilers at configure time, and suggested migration shouldn't overwrite
- theuni (member, neutral, 1 statements 2026-10-23 to 2026-10-23): questioned the usefulness of the test and suggested alternative approaches
Files
26 lines under test/bench/ci.
- src/test/fs_tests.cpp +26/-0
Card
The short text the ranking pass compares across PRs.
Adds a unit test in fs_tests to verify that fs::copy_file with overwrite_existing works correctly. Certain GCC libstdc++ releases targeting Windows (such as GCC 14.2.0) throw a filesystem error claiming the file exists even when overwrite_existing is specified. Wallet migration relies on this function during BerkeleyRODatabase::Backup, and the new test ensures affected toolchains fail CI fs_tests.
Data
thread read through 2026-10-26 (12 statements), head 37c2ad655b
labels: Tests
Categories
Test infrastructure
P3 · test coverage
Adds a unit test in fs_tests to detect an upstream libstdc++ toolchain bug on Windows. The PR description notes that BerkeleyRODatabase::Backup() in src/wallet/migrate.cpp relies on fs::copy_file overwriting existing files, which fails under GCC 12.x to 14.2 cross-compilation with a 'File exists' error.
Membership: Matches 'Tests' label and modifies unit test suite in 'src/test/fs_tests.cpp'.
Factors: security/stability 0, bug 0, performance 0, user value 0, leverage 0