From: Kefu Chai Date: Thu, 4 Jun 2026 10:38:24 +0000 (+0800) Subject: test/rgw/posix: free the quota handler in TestDriver X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3e5008640bd0c433f5c6983d9c2c5889b1b1a710;p=ceph.git test/rgw/posix: free the quota handler in TestDriver TestDriver::init() allocates quota_handler via RGWQuotaHandler::generate_handler() but nothing frees it. The real POSIXDriver frees it in finalize(), which the unit tests never call, so every fixture that runs init() leaks the handler and the stat caches hanging off it: 274 allocations, ~40KB, all rooted at generate_handler() under ASan: ==6102==ERROR: LeakSanitizer: detected memory leaks Direct leak of 3200 byte(s) in 5 object(s) allocated from: #1 RGWQuotaHandler::generate_handler(...) src/rgw/rgw_quota.cc:989 #2 TestDriver::init(...) src/test/rgw/test_rgw_posix_driver.cc:1100 #3 POSIXDriverTest::SetUp() src/test/rgw/test_rgw_posix_driver.cc:1191 ... SUMMARY: AddressSanitizer: 40099 byte(s) leaked in 274 allocation(s). So free it in ~TestDriver(), the counterpart to the init() allocation. ~POSIXDriver() is empty and nothing else touches quota_handler, so there is no double free, and free_handler(nullptr) is a no-op when init() bailed out early. Signed-off-by: Kefu Chai --- diff --git a/src/test/rgw/test_rgw_posix_driver.cc b/src/test/rgw/test_rgw_posix_driver.cc index 1b4574cc4c2..73f53fd245f 100644 --- a/src/test/rgw/test_rgw_posix_driver.cc +++ b/src/test/rgw/test_rgw_posix_driver.cc @@ -1073,7 +1073,9 @@ public: TestDriver(std::string _base_path) : POSIXDriver(nullptr), driver_base(_base_path) { } - virtual ~TestDriver() = default; + virtual ~TestDriver() { + RGWQuotaHandler::free_handler(quota_handler); + } int init(const DoutPrefixProvider* dpp) {