Bug #80488
closedrgw-multisite: RGWRealmReloader use-after-free during shutdown
0%
Description
radosgw can segfault during shutdown if a multisite realm/period notification arrives just before the process receives its stop signal.
Reproducer:
1. configure multisite with two zones
2. issue period update commit on one zone
3. simultaneously restart rgw on the other zone.
its a timing race involving a failover->failback test with promoting a zone, committing a period, and restarting the radosgw in quick succession.
log sequence at the time of crash:
9330803:2026-09-10T18:15:37.173-0400 7fc0837d96c0 4 rgw period pusher: Zone master pushing period bfb9db4c-94db-40be-8e0d-46f5e01340cc epoch 8 to 1 other zones 9330847:2026-09-10T18:15:37.174-0400 7fc07e7cf6c0 1 rgw realm reloader: Pausing frontends for realm update... 9330874:2026-09-10T18:15:37.176-0400 7fc07e7cf6c0 1 rgw realm reloader: Frontends paused 9331775:2026-09-10T18:15:37.217-0400 7fc1b8a856c0 1 handle_sigterm 9331776:2026-09-10T18:15:37.217-0400 7fc1b8a856c0 1 handle_sigterm set alarm for 120 9333637:2026-09-10T18:15:46.875-0400 7fc07e7cf6c0 1 rgw realm reloader: driver closed 9333650:2026-09-10T18:15:46.879-0400 7fc07e7cf6c0 1 rgw realm reloader: Creating new driver 9335193:2026-09-10T18:15:47.156-0400 7fc07e7cf6c0 -1 *** Caught signal (Segmentation fault) **
2026-09-10T18:15:47.156-0400 7fc07e7cf6c0 -1 *** Caught signal (Segmentation fault) ** in thread 7fc07e7cf6c0 thread_name:safe_timer ceph version Development (no_version) tentacle (stable - Debug) 1: bin/radosgw(+0x2a35146) [0x564618d58146] 2: /lib64/libc.so.6(+0x3dbb0) [0x7fc1bb65fbb0] 3: (RGWRealmReloader::reload()+0xf81) [0x56461812ed3f] 4: (RGWRealmReloader::C_Reload::finish(int)+0xd) [0x56461812f345] 5: (Context::complete(int)+0x9) [0x56461803bc7b] 6: (CommonSafeTimer<ceph::mutex_debug_detail::mutex_debug_impl<false> >::timer_thread()+0x266) [0x7fc1bcacea3e] 7: (CommonSafeTimerThread<ceph::mutex_debug_detail::mutex_debug_impl<false> >::entry()+0xd) [0x7fc1bcaceff5] 8: (Thread::entry_wrapper()+0x2f) [0x7fc1bcac7bdf] 9: (Thread::_entry_func(void*)+0x9) [0x7fc1bcac7bf1] 10: /lib64/libc.so.6(+0x8c947) [0x7fc1bb6ae947] 11: /lib64/libc.so.6(+0x112860) [0x7fc1bb734860] NOTE: a copy of the executable, or `objdump -rdS <executable>` is needed to interpret this.
crashing thread was 7fc07e7cf6c0
Thread 1 (Thread 0x7fc07e7cf6c0 (LWP 1048225)): #0 0x00007fc1bb6b0884 in __pthread_kill_implementation () from /lib64/libc.so.6 #1 0x00007fc1bb65fafe in raise () from /lib64/libc.so.6 #2 0x0000564618d56fd8 in reraise_fatal (signum=signum@entry=11) at /root/ceph/src/global/signal_handler.cc:88 #3 0x0000564618d583b9 in handle_oneshot_fatal_signal (signum=11) at /root/ceph/src/global/signal_handler.cc:367 #4 <signal handler called> #5 0x000056461812ed3f in RGWRealmReloader::reload (this=0x56462140f6c0) at /root/ceph/src/rgw/rgw_realm_reloader.cc:205 #6 0x000056461812f345 in RGWRealmReloader::C_Reload::finish (this=<optimized out>, r=<optimized out>) at /root/ceph/src/rgw/rgw_realm_reloader.cc:58 #7 0x000056461803bc7b in Context::complete (this=0x564623c5e260, r=<optimized out>) at /root/ceph/src/include/Context.h:102 #8 0x00007fc1bcacea3e in CommonSafeTimer<ceph::mutex_debug_detail::mutex_debug_impl<false> >::timer_thread (this=0x56462140f6f0) at /root/ceph/src/common/Timer.cc:113 #9 0x00007fc1bcaceff5 in CommonSafeTimerThread<ceph::mutex_debug_detail::mutex_debug_impl<false> >::entry (this=<optimized out>) at /root/ceph/src/common/Timer.cc:33 #10 0x00007fc1bcac7bdf in Thread::entry_wrapper (this=0x564621b2e5c0) at /root/ceph/src/common/Thread.cc:87 #11 0x00007fc1bcac7bf1 in Thread::_entry_func (arg=<optimized out>) at /root/ceph/src/common/Thread.cc:74 #12 0x00007fc1bb6ae947 in start_thread () from /lib64/libc.so.6 #13 0x00007fc1bb734860 in clone3 () from /lib64/libc.so.6
(gdb) frame 5
205 frontends->resume(env.driver);
(gdb) print this->frontends
$1 = (RGWRealmReloader::Pauser * const) 0x56461c4d0760
the thread destroying it was 0x7fc1b92dfdc0
Thread 36 (Thread 0x7fc1b92dfdc0 (LWP 1046947)): #0 0x00007fc1bb6ab219 in __futex_abstimed_wait_common () from /lib64/libc.so.6 #1 0x00007fc1bb6b0623 in __pthread_clockjoin_ex () from /lib64/libc.so.6 #2 0x00007fc1bcac7e37 in Thread::join (this=0x564621b2e5c0, prval=prval@entry=0x0) at /root/ceph/src/common/Thread.cc:176 #3 0x00007fc1bcacfed0 in CommonSafeTimer<ceph::mutex_debug_detail::mutex_debug_impl<false> >::shutdown (this=this@entry=0x56462140f6f0) at /root/ceph/src/common/Timer.cc:71 #4 0x000056461812f202 in RGWRealmReloader::~RGWRealmReloader (this=0x56462140f6c0, __in_chrg=<optimized out>) at /root/ceph/src/rgw/rgw_realm_reloader.cc:51 #5 0x000056461812f24b in RGWRealmReloader::~RGWRealmReloader (this=0x56462140f6c0, __in_chrg=<optimized out>) at /root/ceph/src/rgw/rgw_realm_reloader.cc:52 #6 0x0000564618047404 in std::default_delete<RGWRealmReloader>::operator() (__ptr=<optimized out>, this=<optimized out>) at /usr/include/c++/13/bits/unique_ptr.h:93 #7 std::__uniq_ptr_impl<RGWRealmReloader, std::default_delete<RGWRealmReloader> >::reset (__p=0x0, this=0x7fff5112f760) at /usr/include/c++/13/bits/unique_ptr.h:211 #8 std::unique_ptr<RGWRealmReloader, std::default_delete<RGWRealmReloader> >::reset (__p=0x0, this=0x7fff5112f760) at /usr/include/c++/13/bits/unique_ptr.h:509 #9 rgw::AppMain::shutdown(std::function<void ()>) (this=this@entry=0x7fff5112f600, finalize_async_signals=...) at /root/ceph/src/rgw/rgw_appmain.cc:821 #10 0x000056461803b8b5 in main (argc=<optimized out>, argv=<optimized out>) at /root/ceph/src/rgw/rgw_main.cc:198
(gdb) frame 9
rgw::AppMain::shutdown(std::function<void ()>) (this=this@entry=0x7fff5112f600, finalize_async_signals=...)
at /root/ceph/src/rgw/rgw_appmain.cc:821
(gdb) print this->rgw_pauser
$3 = std::unique_ptr<RGWPauser> = {get() = 0x0}
(gdb) print this->fe_pauser
$4 = std::unique_ptr<RGWFrontendPauser> = {get() = 0x0}
rgw_pauser, fe_pauser are already null. so it looks like the rgw shutdown destroyed the frontend pauser while a realm reload operation was still running. and the reload op later tries to resume the frontends through the already destroyed object causing use-after-free.
I think we should re-order the shutdown sequence such that the reloader is stopped first before removing anything it depends on.
current sequence is:
void rgw::AppMain::shutdown(std::function<void(void)> finalize_async_signals)
{
// stop the realm reloader
rgw_pauser.reset();
fe_pauser.reset();
realm_watcher.reset();
reloader.reset();
YS Updated by Yuechi Sun about 1 month ago
- Has duplicate Bug #82140: rgw: segfault on SIGTERM while a realm reload is in progress added
SM Updated by Shilpa MJ about 1 month ago
- Pull request ID changed from 71739 to 73134
SM Updated by Shilpa MJ about 1 month ago
- Assignee changed from Shilpa MJ to Yuechi Sun
UB Updated by Upkeep Bot 30 days ago
- Status changed from Fix Under Review to Resolved
- Merge Commit set to ae8e3c27c6ec651cb943219fe4f8f2dd8b3e7e90
- Fixed In set to v22.0.0-349-gae8e3c27c6
- Upkeep Timestamp set to 2026-11-03T09:57:18+00:00