{
 "number": 36620,
 "repo": "bitcoin/bitcoin",
 "url": "https://github.com/bitcoin/bitcoin/pull/36620",
 "title": "test: Add case for libstdc++ bug on Windows",
 "author": "hebasto",
 "author_association": "MEMBER",
 "created_at": "2026-10-23T10:01:35Z",
 "updated_at": "2026-10-30T13:00:57Z",
 "description_hash": "e9c838ded34885e2",
 "age_days": 9,
 "draft": false,
 "labels": [
  "Tests"
 ],
 "milestone": null,
 "base": "master",
 "head_sha": "37c2ad655bc2229451fe01801e6db1cd86ff1618",
 "head_ref": "261023-win-libstdcxx",
 "head_repo": "hebasto/bitcoin",
 "head_history": [
  {
   "t": "2026-10-23T10:40:25Z",
   "sha": "37c2ad655bc2229451fe01801e6db1cd86ff1618"
  }
 ],
 "additions": 26,
 "deletions": 0,
 "changed_files": 1,
 "commit_count": 1,
 "size_bucket": "S",
 "mergeable_state": "clean",
 "bot": {
  "drahtbot": {
   "present": true,
   "reviews": {},
   "conflicts": []
  }
 },
 "acks_parsed": {},
 "acks_tally": {
  "ack": 0,
  "stale_ack": 0,
  "concept_ack": 0,
  "approach_ack": 0,
  "nack": 0,
  "concept_nack": 0,
  "approach_nack": 0
 },
 "reviews": {
  "approved": 0,
  "changes_requested": 0,
  "distinct_reviewers": [
   "fanquake",
   "maflcko",
   "theuni"
  ]
 },
 "signals": {
  "needs_rebase": false,
  "ci_failed": false,
  "mergeable_state": "clean",
  "last_author_activity": "2026-10-24T08:10:58Z",
  "last_reviewer_activity": "2026-10-26T16:00:23Z",
  "last_reviewer": "maflcko",
  "author_silent_days": 8,
  "waiting_on_author_days": 6,
  "days_since_update": 2
 },
 "refs": {
  "mentioned": [
   36042
  ],
  "depends_on": [],
  "fixes": [],
  "linked_issues": [],
  "references": [
   {
    "number": 36042,
    "type": "pull",
    "state": "open",
    "merged": false,
    "merged_at": null,
    "title": "build: Bump g++ minimum supported version to 13"
   }
  ],
  "conflicts": []
 },
 "stack": {
  "shares_commits_with": [],
  "based_on": [],
  "base_for": []
 },
 "review_paths": [
  "src/test/fs_tests.cpp"
 ],
 "body": "The [code](https://github.com/bitcoin/bitcoin/blob/152a55397e451fed9c10041bddf01aa6839847d5/src/wallet/migrate.cpp#L745) in `BerkeleyRODatabase::Backup()` relies on `copy_file()` with `overwrite_existing` working.\n\nUpstream fixes:\n- https://github.com/gcc-mirror/gcc/commit/017e3f89b081e4828a588a3bd27b5feacea042b7\n- https://github.com/gcc-mirror/gcc/commit/35c98149a5c7af9159fa7615d8d827b3aaa3cc97\n- https://github.com/gcc-mirror/gcc/commit/8b3e47b4099f319e38d357f7c646f51040a13d6e\n\nSuggested in https://github.com/bitcoin/bitcoin/pull/36271#issuecomment-5794127014.\n\n[Here](https://github.com/hebasto/bitcoin/actions/runs/39924174253/job/120344755756#step:10:1943) is an example of the failure when cross-compiling for Windows using GCC 14.2.0:\n```\n./test/fs_tests.cpp(145): Entering test case \"copy_file_overwrite_existing\"\nunknown location(0): fatal error: in \"fs_tests/copy_file_overwrite_existing\": std::filesystem::__cxx11::filesystem_error: filesystem error: cannot copy file: File exists [C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\test_common bitcoin\\fs_tests\\copy_file_overwrite_existing\\c72b38273c1f6fce4336\\a] [C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\test_common bitcoin\\fs_tests\\copy_file_overwrite_existing\\c72b38273c1f6fce4336\\b]\n./test/fs_tests.cpp(155): last checkpoint\n```",
 "commits": [
  {
   "sha": "37c2ad655bc2229451fe01801e6db1cd86ff1618",
   "date": "2026-10-23T10:39:16Z",
   "message": "test: Add case for libstdc++ bug on Windows\n\nThe code in `BerkeleyRODatabase::Backup()` relies on `copy_file()` with\n`overwrite_existing` working.\n\nUpstream fixes:\n- https://github.com/gcc-mirror/gcc/commit/017e3f89b081e4828a588a3bd27b5feacea042b7\n- https://github.com/gcc-mirror/gcc/commit/35c98149a5c7af9159fa7615d8d827b3aaa3cc97\n- https://github.com/gcc-mirror/gcc/commit/8b3e47b4099f319e38d357f7c646f51040a13d6e"
  }
 ],
 "timeline": [
  {
   "t": "2026-10-23T10:03:04Z",
   "kind": "comment",
   "who": "hebasto",
   "assoc": "MEMBER",
   "text": "[quoted text omitted]\n\nThis can be done, for instance, with the following patch:\n```diff\n--- a/contrib/devtools/shell-win64-cross.nix\n+++ b/contrib/devtools/shell-win64-cross.nix\n@@ -16,9 +16,18 @@ let\n   });\n   toolchain = crossPkgs.stdenv.cc.targetPrefix;\n   pthreads = crossPkgs.windows.pthreads;\n+  gccVersion = \"14.2.0\";\n   crossGcc = crossPkgs.buildPackages.gcc14;\n-  gcc = crossGcc.override {\n+  gcc = (crossGcc.override {\n     cc = crossGcc.cc.overrideAttrs (old: {\n+      version = gccVersion;\n+      name = builtins.replaceStrings [ old.version ] [ gccVersion ] old.name;\n+      postPatch = builtins.replaceStrings [ old.version ] [ gccVersion ] old.postPatch;\n+      configureFlags = map (builtins.replaceStrings [ old.version ] [ gccVersion ]) old.configureFlags;\n+      src = pkgs.fetchurl {\n+        url = \"mirror://gcc/releases/gcc-${gccVersion}/gcc-${gccVersion}.tar.xz\";\n+        sha256 = \"a7b39bc69cbf9e25826c5a60ab26477001f7c08d85cec04bc0e29cabed6f3cc9\";\n+      };\n       # Keep target pthread headers out of GCC's native build tools.\n       env = old.env // {\n         EXTRA_FLAGS_FOR_TARGET =\n@@ -28,7 +37,9 @@ let\n       };\n     });\n     extraPackages = [ pthreads ];\n-  };\n+  }).overrideAttrs (_: {\n+    version = gccVersion;\n+  });\n in\n\n pkgs.mkShellNoCC {\n```",
   "id": "c:6362404375",
   "url": "https://github.com/bitcoin/bitcoin/pull/36620#issuecomment-6362404375",
   "hash": "f44d973f63ff8579",
   "edited": null
  },
  {
   "t": "2026-10-23T10:17:01Z",
   "kind": "comment",
   "who": "maflcko",
   "assoc": "MEMBER",
   "text": "Could address the Ralph comment?",
   "id": "c:6362646569",
   "url": "https://github.com/bitcoin/bitcoin/pull/36620#issuecomment-6362646569",
   "hash": "9a6151c080743b42",
   "edited": null
  },
  {
   "t": "2026-10-23T10:20:12Z",
   "kind": "comment",
   "who": "fanquake",
   "assoc": "MEMBER",
   "text": "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?",
   "id": "c:6362699977",
   "url": "https://github.com/bitcoin/bitcoin/pull/36620#issuecomment-6362699977",
   "hash": "d264516443658590",
   "edited": null
  },
  {
   "t": "2026-10-23T10:29:15Z",
   "kind": "comment",
   "who": "hebasto",
   "assoc": "MEMBER",
   "text": "[quoted text omitted]\n\nEven after #36042, users can hit this bug in a build environment we don\u2019t control (e.g. a distro\u2019s `g++-mingw-w64-ucrt64` package) that formally meets our minimum requirements but ships an affected libstdc++.",
   "id": "c:6362851103",
   "url": "https://github.com/bitcoin/bitcoin/pull/36620#issuecomment-6362851103",
   "hash": "3703c0785115f211",
   "edited": null
  },
  {
   "t": "2026-10-23T10:31:25Z",
   "kind": "comment",
   "who": "maflcko",
   "assoc": "MEMBER",
   "text": "Seems harmless to add the test. An alternative could be to reject g++-mingw less than 14.3 during configure?",
   "id": "c:6362887361",
   "url": "https://github.com/bitcoin/bitcoin/pull/36620#issuecomment-6362887361",
   "hash": "e57e78cb128fcaf4",
   "edited": null
  },
  {
   "t": "2026-10-23T10:40:25Z",
   "kind": "force_push",
   "who": "hebasto",
   "commit": "37c2ad655bc2229451fe01801e6db1cd86ff1618",
   "id": "push:37c2ad655bc2229451fe01801e6db1cd86ff1618"
  },
  {
   "t": "2026-10-23T10:41:02Z",
   "kind": "comment",
   "who": "hebasto",
   "assoc": "MEMBER",
   "text": "[quoted text omitted]\n\nDone.",
   "id": "c:6363045004",
   "url": "https://github.com/bitcoin/bitcoin/pull/36620#issuecomment-6363045004",
   "hash": "6ca4592ed5564a95",
   "edited": null
  },
  {
   "t": "2026-10-23T10:41:08Z",
   "kind": "comment",
   "who": "fanquake",
   "assoc": "MEMBER",
   "text": "[quoted text omitted]\n\nThanks:\n[quoted text omitted]\n\nIt'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.\n\nIt'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?\n\nThere 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.",
   "id": "c:6363046844",
   "url": "https://github.com/bitcoin/bitcoin/pull/36620#issuecomment-6363046844",
   "hash": "74aba9d2330d4df7",
   "edited": "2026-10-23T10:47:47Z"
  },
  {
   "t": "2026-10-23T11:17:33Z",
   "kind": "review_comment",
   "who": "fanquake",
   "assoc": "MEMBER",
   "path": "src/test/fs_tests.cpp",
   "commit": "37c2ad655bc2229451fe01801e6db1cd86ff1618",
   "in_reply_to": null,
   "text": "[quoted text omitted]\n\nOne other point here is that we have been shipping Windows release binaries (`28.0` with `12.4.0` & `29.0`/`30.0` with `13.3.0`), which should have this bug. `30.0` is 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?",
   "id": "rc:4358942336",
   "url": "https://github.com/bitcoin/bitcoin/pull/36620#discussion_r4358942336",
   "hash": "d3db13b7b4d72f20",
   "edited": null
  },
  {
   "t": "2026-10-23T13:16:52Z",
   "kind": "comment",
   "who": "hebasto",
   "assoc": "MEMBER",
   "text": "I have to admit that I can\u2019t see a real-life scenario in which the bug affects users.\n\nThe code is reachable only when migrating a legacy BDB wallet, either via the `migratewallet` RPC command or via the GUI.\n\nThe `dest` argument of `BerkeleyRODatabase::Backup()` is constructed in `MigrateLegacyToDescriptor()` 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.",
   "id": "c:6365775124",
   "url": "https://github.com/bitcoin/bitcoin/pull/36620#issuecomment-6365775124",
   "hash": "0611e6ca20ab5445",
   "edited": null
  },
  {
   "t": "2026-10-23T18:27:10Z",
   "kind": "comment",
   "who": "theuni",
   "assoc": "MEMBER",
   "text": "It seems to me this is either:\n- A compiler config not worth worrying about\n- A compiler config worth explicitly blocking as suggested by @maflcko\n- A compiler config we're worried about, in which case we could just remove the `copy_options` param from `copy_file` so that we can't hit this anywhere else.\n\nEither way, adding a test that fails where we expect it to fail doesn't seem very helpful to me.",
   "id": "c:6371922580",
   "url": "https://github.com/bitcoin/bitcoin/pull/36620#issuecomment-6371922580",
   "hash": "825a42bc534906ee",
   "edited": null
  },
  {
   "t": "2026-10-24T08:10:58Z",
   "kind": "comment",
   "who": "hebasto",
   "assoc": "MEMBER",
   "text": "[quoted text omitted]\n\n@achow101\n\nCould we?",
   "id": "c:6381835429",
   "url": "https://github.com/bitcoin/bitcoin/pull/36620#issuecomment-6381835429",
   "hash": "f23a20ba1ef611f1",
   "edited": null
  },
  {
   "t": "2026-10-26T16:00:23Z",
   "kind": "comment",
   "who": "maflcko",
   "assoc": "MEMBER",
   "text": "[quoted text omitted]\n\nIt seems like a bugfix, because migration shouldn't overwrite?",
   "id": "c:6420696121",
   "url": "https://github.com/bitcoin/bitcoin/pull/36620#issuecomment-6420696121",
   "hash": "65dca38658238d78",
   "edited": null
  }
 ],
 "labels_log": [
  {
   "t": "2026-10-23T10:01:36Z",
   "action": "labeled",
   "label": "Tests",
   "who": "hebasto"
  },
  {
   "t": "2026-10-23T10:40:56Z",
   "action": "labeled",
   "label": "CI failed",
   "who": "DrahtBot"
  },
  {
   "t": "2026-10-23T11:45:49Z",
   "action": "unlabeled",
   "label": "CI failed",
   "who": "DrahtBot"
  }
 ],
 "state_log": [],
 "text_chars": 5899,
 "text_tokens_estimate": 1474,
 "changed_paths": [
  "src/test/fs_tests.cpp"
 ],
 "files": [
  {
   "path": "src/test/fs_tests.cpp",
   "add": 26,
   "del": 0
  }
 ],
 "test_lines": 26,
 "git": {
  "head": "37c2ad655bc2229451fe01801e6db1cd86ff1618",
  "head_matches_backup": true,
  "base": "152a55397e451fed9c10041bddf01aa6839847d5",
  "patch_id": "ae94d487f3c7a82f",
  "commits": [
   {
    "sha": "37c2ad655b",
    "subject": "test: Add case for libstdc++ bug on Windows",
    "files": 1,
    "add": 26,
    "del": 0
   }
  ],
  "patch_truncated": false
 },
 "patch_id": "ae94d487f3c7a82f",
 "input_hash": "6544eb8d9b306070",
 "extracted_at": "2026-11-02T01:09:49+00:00"
}