]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test/rgw/posix: free the quota handler in TestDriver 69285/head
authorKefu Chai <k.chai@proxmox.com>
Thu, 4 Jun 2026 10:38:24 +0000 (18:38 +0800)
committerKefu Chai <k.chai@proxmox.com>
Thu, 4 Jun 2026 10:44:03 +0000 (18:44 +0800)
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 <k.chai@proxmox.com>
src/test/rgw/test_rgw_posix_driver.cc

index 1b4574cc4c255a25f4d1080c17157b1ce9c249b9..73f53fd245f8a2f8ebf3e0386df776e0d40dd7c5 100644 (file)
@@ -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)
   {