Skip to content

Conversation

luke-jr
Copy link
Member

@luke-jr luke-jr commented Jul 13, 2020

Previously, an exception would be thrown, which could kill the node in some circumstances.

Includes test changes to cause failure.

Review with ?w=1

Copy link
Member

@jonatack jonatack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK bca838d

@DrahtBot
Copy link
Contributor

DrahtBot commented Jul 13, 2020

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

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.

@jonatack
Copy link
Member

ACK 4f0cbc4

@bitcoin bitcoin deleted a comment from Aonny112 Jul 14, 2020
Copy link
Contributor

@meshcollider meshcollider left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review ACK 4f0cbc4

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reviewed 4f0cbc4 and ready to ACK after rebasing.

@luke-jr luke-jr force-pushed the bugfix_listwalletdir_errors branch from 4f0cbc4 to 1e77a8d Compare October 12, 2020 15:53
@luke-jr
Copy link
Member Author

luke-jr commented Oct 12, 2020

Rebased

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 1e77a8d, I have reviewed the code and it looks OK, I agree it can be merged.

Copy link
Member

@jonatack jonatack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re-ACK 1e77a8d

In the new test, the new exception prints:

[httpworker.1] ListWalletDir: Error scanning /tmp/bitcoin_func_test_ql5k4c0f/node0/regtest/wallets/self_walletdat_symlink: boost::filesystem::status: Too many levels of symbolic links: "/tmp/bitcoin_func_test_ql5k4c0f/node0/regtest/wallets/self_walletdat_symlink/wallet.dat"

[httpworker.1] ListWalletDir: Error scanning /tmp/bitcoin_func_test_ql5k4c0f/node0/regtest/wallets/self_walletdat_symlink/wallet.dat: boost::filesystem::status: Too many levels of symbolic links: "/tmp/bitcoin_func_test_ql5k4c0f/node0/regtest/wallets/self_walletdat_symlink/wallet.dat"`

@Saibato
Copy link
Contributor

Saibato commented Oct 13, 2020

nit: Before merge please note; this ( #19502 and ( #20080 or #19933 ) should merged together, since they vice versa would create new issues, like shorted wallet names.

If we have boost cononical best first #20080 and then this.

@luke-jr
Copy link
Member Author

luke-jr commented Oct 13, 2020

I don't see what new issues (aside from rebasing) would be created by merging them separately?

@Saibato
Copy link
Contributor

Saibato commented Oct 13, 2020

I don't see what new issues (aside from rebasing) would be created by merging them separately?

iirc this a fix for the boost link problem and ( evil wallet ) and makes #18095 obsolete.

̶B̶u̶t̶ ̶i̶f̶ ̶t̶h̶i̶s̶ ̶g̶e̶t̶ ̶m̶e̶r̶g̶e̶d̶ ̶f̶i̶r̶s̶t̶,̶ ̶t̶h̶e̶n̶ ̶r̶e̶a̶l̶ ̶s̶h̶o̶r̶t̶ ̶f̶i̶l̶e̶n̶a̶m̶e̶s̶ ̶w̶a̶l̶l̶e̶t̶s̶ ̶f̶r̶o̶m̶ ̶t̶h̶e̶ ̶l̶a̶t̶e̶r̶ ̶f̶o̶u̶n̶d̶ ̶b̶u̶g̶ ̶c̶o̶u̶l̶d̶ ̶b̶e̶ ̶c̶r̶e̶a̶t̶e̶d̶ ̶f̶r̶o̶m̶ ̶a̶ ̶b̶o̶g̶u̶s̶ ̶d̶i̶r̶n̶a̶m̶e̶ ̶o̶n̶ ̶d̶i̶s̶k̶ ̶f̶o̶r̶ ̶r̶e̶a̶l̶.̶

luke-jr added a commit to luke-jr/bitcoin that referenced this pull request Oct 13, 2020
luke-jr added a commit to luke-jr/bitcoin that referenced this pull request Oct 13, 2020
Copy link
Contributor

@meshcollider meshcollider left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re-utACK 1e77a8d

@Saibato
Copy link
Contributor

Saibato commented Oct 14, 2020

But if this get merged first, then real short filenames wallets from the later found bug could be created from a bogus dirname on disk for real.

@luke-jr
Rechecked complies from the sources: To open non exitsting files, is no longer the case with current master and knots so no merge sequence preferences here any longer. Was only a problem short after those errors where found and exits only if direct on top of last releases before/= 0.20

@luke-jr luke-jr force-pushed the bugfix_listwalletdir_errors branch from 1e77a8d to 9f74b7b Compare October 15, 2020 19:32
@hebasto
Copy link
Member

hebasto commented Oct 20, 2020

I revoke my ACK as this change makes possible an infinity loop.
To reproduce the bug, one could create a directory without access permissions, e.g.:

$ ls -l /home/hebasto/bitcoin-data-dir/wallets
total 1456
drwx------ 3 hebasto hebasto    4096 Oct  3 11:16 20191109-main
drwx------ 2 root    root       4096 Oct 20 23:58 crash
-rw-r--r-- 1 hebasto hebasto       0 Mar  5  2020 db.log
drwx------ 3 hebasto hebasto    4096 Oct 20 23:56 w20201015.bdb
drwx------ 3 hebasto hebasto    4096 Oct 20 23:56 w20201015.desc
-rw-r----- 1 hebasto hebasto 1474560 Sep 12 16:08 wallet.dat

I suggest to combine into this PR the approach from #18095:

auto it = fs::recursive_directory_iterator(wallet_dir, ec);
if (ec) {
LogPrintf("%s: iterator: %s %s\n", __func__, ec.message(), it->path().string());
return paths;
}
for (; it != fs::recursive_directory_iterator(); it.increment(ec)) {
if (ec) {
LogPrintf("%s: increment: %s %s\n", __func__, ec.message(), it->path().string());
it.no_push();
continue;
}

with credits to @uhliksk

@luke-jr
Copy link
Member Author

luke-jr commented Oct 29, 2020

@hebasto Couldn't reproduce, but it did cause listwallets to miss other wallets. Added a fix and test.

@luke-jr luke-jr requested a review from hebasto October 29, 2020 19:04
@hebasto
Copy link
Member

hebasto commented Oct 29, 2020

Tested 49cc691, still able to reproduce an infinite loop:

cd <path-to-wallet-dir>
sudo mkdir crash
sudo chown 0700 crash

then start a node, and initiate a ListWalletDir call in any way.

@luke-jr luke-jr force-pushed the bugfix_listwalletdir_errors branch 2 times, most recently from 49cc691 to 44c0bc3 Compare October 29, 2020 20:32
Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approach ACK 44c0bc3, tested on Linux Mint 20 (x86_64).

Instead of an infinite loop having a nice log message:

2020-10-29T20:41:26Z [main] ListWalletDir: Error scanning /home/hebasto/.bitcoin/testnet3/wallets/crash: boost::filesystem::status: Permission denied: "/home/hebasto/.bitcoin/testnet3/wallets/crash/wallet.dat"

Keeping reviewing the last commit.

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 44c0bc3

@luke-jr luke-jr force-pushed the bugfix_listwalletdir_errors branch from 44c0bc3 to 24d2d33 Compare November 6, 2020 04:36
Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re-ACK 24d2d33, rebased only since my previous review.

Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested ACK 24d2d33, test change fails on master.

nit, could squash.

}
} catch (const std::exception& e) {
LogPrintf("%s: Error scanning %s: %s\n", __func__, it->path().string(), e.what());
it.no_push();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, TIL

Copy link
Contributor

@meshcollider meshcollider left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK 24d2d33

@meshcollider meshcollider merged commit c2d8ba6 into bitcoin:master Nov 12, 2020
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Nov 12, 2020
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants