-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Add error handling to all boost filesystem functions #18189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add error handling to all boost filesystem functions #18189
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK
What a great first-time contribution! Hope to see more contributions from you :)
@@ -133,7 +133,7 @@ CDBWrapper::CDBWrapper(const fs::path& path, size_t nCacheSize, bool fMemory, bo | |||
leveldb::Status result = leveldb::DestroyDB(path.string(), options); | |||
dbwrapper_private::HandleError(result); | |||
} | |||
TryCreateDirectories(path); | |||
assert(TryCreateDirectories(path)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert(…)
:s should not have side-effects :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, sorry, I was debugging and I forgot to handle this correctly. I'll add proper error handling here in additional commit.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK.
LogPrintf("%s: Unable to remove PID file: File does not exist\n", __func__); | ||
} | ||
} catch (const fs::filesystem_error& e) { | ||
LogPrintf("%s: Unable to remove PID file: %s\n", __func__, fsbridge::get_filesystem_error_message(e)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems fine as is (catching the error), no?
🐙 This pull request conflicts with the target branch and needs rebase. |
Hi @uhliksk - pinging for rebase and response to question above. |
Hi @adamjonas , sorry for delay, I'll be back on June 1st. |
Hi @uhliksk, friendly monthly ping. |
Hi @adamjonas, I'm alive but I had to postpone my work again. I'll be back soon. |
Going to close this for now. Let us know if/when you have time to work on it again and it can be re-opened. |
All boost filesystem functions should be handled using error code to prevent random crashes caused by inaccesible files or directories. Increment in iterator should use separate error code variable because it have to be handled specifically to prevent infinite loop in diving to inaccessible directories.
To prevent coding errors in future the lint test is added to check if error code parameters are present.
Previous conversation about issue in #18095