]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
test/erasure-code: fix memory leak in ErasureCodePlugin.parity_delta_write 63840/head
authorKefu Chai <tchaikov@gmail.com>
Tue, 10 Jun 2025 09:59:28 +0000 (17:59 +0800)
committerKefu Chai <tchaikov@gmail.com>
Tue, 10 Jun 2025 10:16:32 +0000 (18:16 +0800)
commitc449473c205e4de8981259f9c99fcb40bbe333c5
treeb6b98983daadfd21cac184a2d202600e145fc0ac
parent3fb436a0c703417a3a762503881c401af1a1b4d3
test/erasure-code: fix memory leak in ErasureCodePlugin.parity_delta_write

Fix 4KB memory leak in ErasureCodePlugin_parity_delta_write_Test caused by
unmanaged raw buffer allocation. The test was allocating a 4096-byte raw
buffer to replace shard 4 for delta encoding validation, but the buffer::ptr
constructed from the raw pointer did not manage the buffer's lifecycle.

Detected by AddressSanitizer:

```
Direct leak of 4096 byte(s) in 1 object(s) allocated from:
    #0 0x7fb73a720e15 in malloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:67
    #1 0x5562f4062ccc in ErasureCodePlugin_parity_delta_write_Test::TestBody() /home/kefu/dev/ceph/src/test/erasure-code/TestErasureCodePluginJerasure.cc:122
    #2 0x5562f41081a1 in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /home/kefu/dev/ceph/src/googletest/googletest/src/gtest.cc:2653
    #3 0x5562f40f3004 in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /home/kefu/dev/ceph/src/googletest/googletest/src/gtest.cc:2689
    #4 0x5562f409cbba in testing::Test::Run() /home/kefu/dev/ceph/src/googletest/googletest/src/gtest.cc:2728```
```

In this change, we replace raw pointer allocation with
create_bufferptr() to ensure proper memory management by buffer::ptr.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
src/test/erasure-code/TestErasureCodePluginJerasure.cc