Repository navigation
Open
Description
Having an intermittent error in my local Windows:
> py -3 test\functional\test_runner.py --jobs 40 --timeout-factor=8
...
165/269 - feature_versionbits_warning.py failed, Duration: 59 s
stdout:
2023-09-25T11:29:08.904000Z TestFramework (INFO): PRNG seed is: 6135880998339750841
2023-09-25T11:29:09.019000Z TestFramework (INFO): Initializing test directory C:\Users\hebasto\AppData\Local\Temp\test_runner_₿_🏃_20230925_122333\feature_versionbits_warning_108
2023-09-25T11:29:25.118000Z TestFramework (INFO): Check that there is no warning if previous VB_BLOCKS have <VB_THRESHOLD blocks with unknown versionbits version.
2023-09-25T11:29:43.242000Z TestFramework (INFO): Check that there is a warning if previous VB_BLOCKS have >=VB_THRESHOLD blocks with unknown versionbits version.
2023-09-25T11:29:50.044000Z TestFramework.p2p (WARNING): Connection lost to 127.0.0.1:12296 due to [WinError 10054] An existing connection was forcibly closed by the remote host
2023-09-25T11:30:05.174000Z TestFramework (INFO): Stopping nodes
2023-09-25T11:30:05.548000Z TestFramework (INFO): Cleaning up C:\Users\hebasto\AppData\Local\Temp\test_runner_₿_🏃_20230925_122333\feature_versionbits_warning_108 on exit
2023-09-25T11:30:05.548000Z TestFramework (INFO): Tests successful
stderr:
Traceback (most recent call last):
File "C:\Users\hebasto\bitcoin/test/functional/feature_versionbits_warning.py", line 103, in <module>
VersionBitsWarningTest().main()
File "C:\Users\hebasto\bitcoin\test\functional\test_framework\test_framework.py", line 154, in main
exit_code = self.shutdown()
^^^^^^^^^^^^^^^
File "C:\Users\hebasto\bitcoin\test\functional\test_framework\test_framework.py", line 361, in shutdown
shutil.rmtree(self.options.tmpdir)
File "C:\Python311\Lib\shutil.py", line 759, in rmtree
return _rmtree_unsafe(path, onerror)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\shutil.py", line 617, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:\Python311\Lib\shutil.py", line 617, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:\Python311\Lib\shutil.py", line 622, in _rmtree_unsafe
onerror(os.unlink, fullname, sys.exc_info())
File "C:\Python311\Lib\shutil.py", line 620, in _rmtree_unsafe
os.unlink(fullname)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\hebasto\\AppData\\Local\\Temp\\test_runner_₿_🏃_20230925_122333\\feature_versionbits_warning_108\\node0\\regtest\\debug.log'
166/269 - feature_startupnotify.py passed, Duration: 30 s
...
Activity
maflcko commentedon Sep 25, 2023
See also #28115
hebasto commentedon Sep 25, 2023
Trying to collect some details with Sysinternals
handle64.exemakes the issue disappear 🤷♂️hebasto commentedon Jan 8, 2024
https://github.com/bitcoin/bitcoin/actions/runs/7433919780/job/20227517742:
[-]qa: No access to `debug.log` in functional tests on Windows[/-][+]qa: `PermissionError` in functional tests on Windows[/+]fanquake commentedon Nov 11, 2024
Saw a failure that matches the first portion of the issue here. https://github.com/bitcoin/bitcoin/actions/runs/11781528801/job/32814548437#step:12:69. Unclear if this should be a new issue, but couldn't seem to match it to an existing issue.
maflcko commentedon Nov 11, 2024
Has anyone ever seen any of the warnings or errors locally?
willcl-ark commentedon Oct 21, 2025
Since the problem isn’t easily reproducible, I’m closing this for now. If it occurs again, please feel free to open a new issue or comment here so we can reopen it.
willcl-ark commentedon Mar 13, 2026
I think this has happened again on the merge commit failure earlier today: https://github.com/bitcoin/bitcoin/actions/runs/23042377679/job/66923350385#step:16:585
willcl-ark commentedon Mar 13, 2026
We could "fix" this by adding a timeout/retry around the
rmtreecall in test_framework.py, but I don't really like adding more magic sleeps and loops.I talked with an agent about this:
Details
I then provisioned a new agent create a fix based on this diagnosis, which is commited (with the retry as a commit) in this branch: master...willcl-ark:bitcoin:refs/heads/fix-win-debug-cleanup-race
I won't open it as a PR myself as I don't know much about windows or its APIs (and it's currently 100% vibe-coded), but perhaps it will be useful to someone else looking at fixing this.
maflcko commentedon Mar 13, 2026
Ah nice. I think the LLM is actually correct here.
-blocknotifyis also affected, which could be one thread per block?maflcko commentedon Mar 18, 2026
Actually, on a second though, I am not sure if the LLM is 100% correct.The thread immediately detaches, so Option A to close the fds may not be sufficient, because in theory it can happen at any time in the future (possibly too late).
Edit: The LLM is likely right, because the detached thread will block bitcoind.exe shutdown, until it has forked via
bInheritHandles = FALSE?In any case, I don't have Windows, so I can't reproduce this, but it should be trivial to reproduce by adding a sleep in the detached thread right after running it? Maybe:
Trigger error on Windows
Trigger error on Windows
Trigger error on Windows
hebasto commentedon Mar 19, 2026
hebasto/bitcoin-core-nightly#214
maflcko commentedon Mar 20, 2026
Interesting, looks like it passed. I guess it could make more sense to try to reproduce locally, because debugging in CI usually increases the time between debug cycles.
On a second thought, it is obvious why the sleep does not reproduce the issue: The test has a
wait_untilto wait for the result/side-effect of the _wsystem call.So to reproduce this, there are options:
On a general note, I presume it can only happen outside of tests if the Windows user is using a dedicated folder for the notifications and then tries to delete that folder immediately after bitcoind shutdown.
maflcko commentedon Mar 27, 2026
So to clarify, a correct reproducer would be:
This will deterministically fail with
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'D:\\a\\bitcoin-core-with-ci\\bitcoin-core-with-ci\\test_runner_₿_🏃_20260326_213742\\feature_startupnotify_89\\node0\\regtest\\debug.log'See https://github.com/maflcko/bitcoin-core-with-ci/actions/runs/23616233568/job/68793850155#step:10:22215:
hebasto commentedon Apr 8, 2026
Another instance: https://github.com/hebasto/bitcoin-core-nightly/actions/runs/24118223423/job/70366581262.