mirror of
https://github.com/bitcoin-core/gui-qml.git
synced 2026-12-02 08:12:38 +00:00
Unreadable custom datadir can cause and exception #775
Labels
No labels
Android
Bug
Build system
Design suggestion
Doc
Needs design review
Needs rebase
Stage
UX
Up for grabs
Upstream
Wallet
duplicate
enhancement
good first issue
question
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin-core/gui-qml#775
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Still finishing the rest of my review but I did find a blocker so posting it now.
On Linux, if the saved GUI-selected custom datadir still exists but is no longer readable, the app aborts at launch with an unhandled exception instead of re-showing the datadir chooser:
terminate called after throwing an instance of 'std::filesystem::__cxx11::filesystem_error'
what(): filesystem error: status: Permission denied [/bitcoin.conf]
Aborted (core dumped)
Repro:
Root cause: ResolveOnboardingStartupStatus correctly computes force_show_onboarding (ShouldShowDataDirChooser flags the directory as not writable), but then still reads the profile from it, because the gate is custom_datadir_exists = QFileInfo::exists(...) (qml/onboarding_settings.cpp, around line 406), and a mode-000 directory exists. It applies the datadir to the preview args and calls ReadConfigFiles, where fs::is_directory(conf_path) (src/common/config.cpp:134) stats /bitcoin.conf, gets EACCES, and throws. Nothing on the QML startup path catches std::filesystem_error, so the process terminates.
Suggested fix, two parts:
The existing unit test covers the unwritable case (guiDataDirChooserShowsForUnwritableConfiguredDir) but not the unreadable one, which is why this survives a green suite; a sibling test with a mode-000 directory would pin the fix.
Originally posted by @epicleafies in https://github.com/bitcoin-core/gui-qml/issues/742#issuecomment-4905653972
Flagging that this is a hard crash, not the soft failure the description implies: a GUI-saved custom datadir that exists but cannot be traversed aborts startup before the chooser is shown.
Mechanism (platform-independent):
QFileInfo::existsreturns true for a directory that exists but cannot be traversed, so the pre-init path applies it as-datadirand calls Core'sReadConfigFiles, which throws afilesystem_errorfromfs::is_directory(<datadir>/bitcoin.conf). That throw is uncaught on the QML startup path (ShouldShowPreInitOnboardingruns before the surrounding try), so it terminates. Anyfilesystem_errorout of the pre-init config read would crash the same way; the specific trigger below is POSIX permissions.Reproduction:
chmod 000 <custom-datadir>).-datadir.Observed:
Environment: PR #812 head, Qt 6.4.2, Linux under xcb with software rendering. The mode-000 trigger is POSIX-specific; whether an equivalent untraversable-directory state reproduces on Windows or macOS is untested. A
try/catcharound the pre-init config read routing to the chooser or an error would resolve it.