Repository navigation
common/async: catch all exceptions in call_once() - #71896
Conversation
|
can you please raise a tracker issue that explains what the actual problem is? what non-std exception are you seeing here? |
|
@cbodley I will create a tracker issue for this and try to add a reproducer. To be clear, in current main there is no code path that throws a non-std::exception into call_once(). So this is not a live bug today. I found it while working on https://tracker.ceph.com/issues/67793. My patch routes the keystone auth path through call_once(), and that path reported errors by throwing a bare int. There are 8 such throws in rgw_auth_keystone.cc and 52 across src/rgw. I changed my patch to return the error as a value instead, so it does not hit this. #71929 does the same thing. Its fetch lambda catches const int and returns tl::unexpected, so it does not hit it either. But in my understanding, it might be a bug waiting to happen. The docs on call_once() say "if it throws, that exception is rethrown by all calls". For an int that is not what happens. do_init() returns before wake_all(), the state stays in Wait, and every waiter behind that fetch is never woken. There is no error and no log line, and if the once_result lives in a cache that entry stays stuck. So today it works only because every caller remembers to catch inside the fetch. Compiler won't catch if caller forgets and we get a hang later. |
do_init() only caught std::exception, so any other exception escaping f() left the once_result in its Wait state without calling wake_all(). Every queued caller will be left waiting. The one exception we must not catch is forced_unwind: boost throws it to unwind a fiber being destroyed and requires by design that it propagate, so rethrow it at once as asio does. Add tests that throw an int from f(), as rgw's auth engines do. Fixes: https://tracker.ceph.com/issues/81105 Signed-off-by: Supriti Singh <[email protected]> Assisted-by: Claude Opus 5 (1M context) <[email protected]>
740d98c to
30b1dfc
Compare
| #if defined(BOOST_ASIO_HAS_BOOST_CONTEXT_FIBER) | ||
| } catch (const boost::context::detail::forced_unwind&) { |
There was a problem hiding this comment.
we really shouldn't depend on library internals that aren't part of their public api
i would prefer to fix code paths that throw non-std exceptions, like the rgw auth paths you pointed out
but approving in the meantime
|
@cbodley thanks for approval. I will open a tracker issue to investigate (and change if possible) if rgw code paths can be changed to throw non-std exceptions and add this PR as reference. Can this PR be merged or does it need to be added to some QA list? I am not aware of the process. Thanks. |
|
This PR has been added to main integration testing by anuchaithra started 2026-10-09-10:05. |
pr testing completed and approved by @ivancich, more details in https://tracker.ceph.com/issues/81586. |
|
This is an automated message by src/script/redmine-upkeep.py. I have resolved the following tracker ticket due to the merge of this PR: No backports are pending for the ticket. If this is incorrect, please update the tracker |
|
tracker for fixing code path throwing int https://tracker.ceph.com/issues/81903 |
|
thank you! |
do_init() only caught std::exception, so any other exception escaping f() left the once_result in its Wait state without calling wake_all(). Every queued caller will be left waiting. The one exception we must not catch is forced_unwind: boost throws it to unwind a fiber being destroyed and requires by design that it propagate, so rethrow it at once as asio does.
Add tests that throw an int from f(), as rgw's auth engines do.
Fixes: https://tracker.ceph.com/issues/81105
Assisted-by: Claude Opus 5 (1M context) [email protected]
Contribution Guidelines
To sign and title your commits, please refer to Submitting Patches to Ceph.
If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.
When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an
xbetween the brackets:[x]. Spaces and capitalization matter when checking off items this way.Checklist
Show available Jenkins commands
jenkins test classic perfJenkins Job | Jenkins Job Definitionjenkins test crimson perfJenkins Job | Jenkins Job Definitionjenkins test signedJenkins Job | Jenkins Job Definitionjenkins test make checkJenkins Job | Jenkins Job Definitionjenkins test make check arm64Jenkins Job | Jenkins Job Definitionjenkins test submodulesJenkins Job | Jenkins Job Definitionjenkins test dashboardJenkins Job | Jenkins Job Definitionjenkins test dashboard cephadmJenkins Job | Jenkins Job Definitionjenkins test apiJenkins Job | Jenkins Job Definitionjenkins test docsReadTheDocs | Github Workflow Definitionjenkins test ceph-volume allJenkins Jobs | Jenkins Jobs Definitionjenkins test windowsJenkins Job | Jenkins Job Definitionjenkins test rook e2eJenkins Job | Jenkins Job DefinitionYou must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.