Skip to content

test/erasure-code: fix memory leak in ErasureCodePlugin.parity_delta_…#63840

Merged
tchaikov merged 1 commit intoceph:mainfrom
tchaikov:wip-test-erasure-code-fix-leak
Jun 12, 2025
Merged

test/erasure-code: fix memory leak in ErasureCodePlugin.parity_delta_…#63840
tchaikov merged 1 commit intoceph:mainfrom
tchaikov:wip-test-erasure-code-fix-leak

Conversation

@tchaikov
Copy link
Contributor

@tchaikov tchaikov commented Jun 10, 2025

…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.

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 x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands

…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>
@tchaikov tchaikov requested a review from aainscow June 10, 2025 10:18
@github-actions github-actions bot added the tests label Jun 10, 2025
@tchaikov
Copy link
Contributor Author

@aainscow hi Alex, could you please help review this change?

@aainscow
Copy link
Contributor

Thanks for find/fixing that.

@aainscow
Copy link
Contributor

jenkins test make check

@aainscow
Copy link
Contributor

jenkins test windows

1 similar comment
@tchaikov
Copy link
Contributor Author

jenkins test windows

@tchaikov
Copy link
Contributor Author

jenkins test make check

@tchaikov
Copy link
Contributor Author

jenkins test make check arm64

@tchaikov
Copy link
Contributor Author

jenkins test api

@tchaikov
Copy link
Contributor Author

jenkins test make check arm64

@tchaikov
Copy link
Contributor Author

jenkins test submodules

@tchaikov
Copy link
Contributor Author

jenkins test make check arm64

@tchaikov
Copy link
Contributor Author

jenkins test windows

@tchaikov tchaikov merged commit 5b676c6 into ceph:main Jun 12, 2025
21 checks passed
@tchaikov tchaikov deleted the wip-test-erasure-code-fix-leak branch June 12, 2025 00:30
@tchaikov tchaikov mentioned this pull request Jun 12, 2025
14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants