You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fs::create_directories causes crashes in multiple places when lacking write permission #24953
I expected for the program to keep executing, or to shutdown gracefully, after having displayed and/or logged messages/warnings telling me that write permissions are lacking on the involved filesystem resources. This can affect attempting to write to directories outside of the normal bitcoin data directory and/or blocks directory, as seen in my second example below. The nastier crashes are like the ones in the GUI settings that could happen concurrent to data modification. Those could lead to data corruption when files are not flushed, and/or data gets out of synch.
Actual behavior
The program logged a runaway exception and immediately aborted.
To reproduce
This can be reproduced in multiple ways since there are many references to fs::create_directories. Also, crashes can result from restrictive umask settings too since some calls attempt to create directories multiple levels deep.
Here are two easy ways:
bitcoind "-blocksdir not writable"
start with the command line: mkdir /tmp/blocks && chmod 0500 /tmp/blocks && ./src/bitcoind -blocksdir=/tmp/blocks
the program will immediately crash with this logged in the console:
I wouldn't consider these as bugs. The error, and even the cause of the error "permission denied" is logged or printed, right? Sure, messages could always be nicer, but there's an infinite amount of things that can be wrong with the file system, or underlying assumptions that could be broken, it's not possible to special-case all of them.
Edit: though I have to admit this unrelated assertion error is a bit strange:
I think the 2nd example (the one in the GUI) is a good example that this is a bug because: 1) the crash can cause data loss, 2) it goes beyond the scope of thinking that everything in the data directory has to be writable by the node because it deals with a directory outside of the bitcoin node's data directory. For that one, if you don't set the env var XDG_CONFIG_HOME, like I did to make the test easily reproducible and lightweight, then the default will try to create $HOME/.config/autostart, if it does not exist. If this ends up not being considered a bug, then we should definitely document that having write permissions available on $HOME/.config is a prereq for bitcoin-qt to not crash suddenly.
Activity
laanwj commentedon Apr 23, 2022
I wouldn't consider these as bugs. The error, and even the cause of the error "permission denied" is logged or printed, right? Sure, messages could always be nicer, but there's an infinite amount of things that can be wrong with the file system, or underlying assumptions that could be broken, it's not possible to special-case all of them.
Edit: though I have to admit this unrelated assertion error is a bit strange:
mruddy commentedon Apr 23, 2022
I think the 2nd example (the one in the GUI) is a good example that this is a bug because: 1) the crash can cause data loss, 2) it goes beyond the scope of thinking that everything in the data directory has to be writable by the node because it deals with a directory outside of the bitcoin node's data directory. For that one, if you don't set the env var
XDG_CONFIG_HOME, like I did to make the test easily reproducible and lightweight, then the default will try to create$HOME/.config/autostart, if it does not exist. If this ends up not being considered a bug, then we should definitely document that having write permissions available on$HOME/.configis a prereq for bitcoin-qt to not crash suddenly.gui: avoid unclean exit due to permissions issues when setting start …