Is there an existing issue for this?
- I have searched the existing issues
Current behaviour
0std::vector<CAddress> ReadAnchors(const fs::path& anchors_db_path)
1{
2 std::vector<CAddress> anchors;
3 try {
4 DeserializeFileDB(anchors_db_path, CAddress::V2_DISK(anchors));
5 LogPrintf("Loaded %i addresses from %s\n", anchors.size(), fs::quoted(fs::PathToString(anchors_db_path.filename())));
6 } catch (const std::exception&) {
7 anchors.clear();
8 }
9
10 fs::remove(anchors_db_path);
11 return anchors;
12}
On second run I would get:
EXCEPTION: NSt10filesystem7__cxx1116filesystem_errorE
filesystem error: cannot remove: No such file or directory [… \AppData\Roaming\Bitcoin\anchors.dat]
..\bitcoin-qt.exe in Runaway exception
Attempting blind delete on already-deleted file..
Expected behaviour
No crash on second run, this works for me:
0std::vector<CAddress> ReadAnchors(const fs::path& anchors_db_path)
1{
2 std::vector<CAddress> anchors;
3 try {
4 DeserializeFileDB(anchors_db_path, CAddress::V2_DISK(anchors));
5 LogPrintf("Loaded %i addresses from %s\n", anchors.size(), fs::quoted(fs::PathToString(anchors_db_path.filename())));
6 } catch (const std::exception&) {
7 anchors.clear();
8 }
9
10 if (fs::exists(anchors_db_path)) {
11 try {
12 fs::remove(anchors_db_path);
13 } catch (const std::filesystem::filesystem_error& e) {
14 LogPrintf("Error. %s could not be deleted: %s\n", fs::quoted(fs::PathToString(anchors_db_path.filename())), e.what());
15 }
16 }
17 return anchors;
18}
I emphasize that I am not very familiar with the code base, and there could be reasons for the way this is done. Just trying to better understand it really..
Steps to reproduce
Compile from source MinGW64, run twice..
Relevant log output
No response
How did you obtain Bitcoin Core
Compiled from source
What version of Bitcoin Core are you using?
26.1
Operating system and version
Windows, MinGW64 (using portable_endian.h)
Machine specifications
No response