test/objectstore/test_bluefs: avoid leak of writers#63602
Closed
test/objectstore/test_bluefs: avoid leak of writers#63602
Conversation
14 tasks
Fix two memory leaks in BlueFS test cases:
1. BlueFS instances were mounted but never unmounted, causing log.writer
objects to leak. Added explicit umount() calls at test completion.
2. Created FileWriter objects were not being freed after use. Added
proper cleanup to free writers when no longer needed.
These leaks were detected by AddressSanitizer, which reported a direct
leak in the FileWriter allocation path:
```
Direct leak of 256 byte(s) in 1 object(s) allocated from:
#0 0x55dcd54e9a2d in operator new[](unsigned long) (/home/jenkins-build/build/workspace/ceph-pull-requests/build/bin/unittest_bluefs+0x3b7a2d) (BuildId: a8b1c1bb869c4f8f832195839191cf81d3670f77)
#1 0x55dcd571a5de in mempool::pool_allocator<(mempool::pool_index_t)17, BlueFS::FileWriter>::allocate(unsigned long, void*) /home/jenkins-build/build/workspace/ceph-pull-requests/src/include/mempool.h:353:33
#2 0x55dcd569c020 in BlueFS::FileWriter::operator new(unsigned long) /home/jenkins-build/build/workspace/ceph-pull-requests/src/os/bluestore/BlueFS.cc:52:1
#3 0x55dcd56a8e5a in BlueFS::_create_writer(boost::intrusive_ptr<BlueFS::File>) /home/jenkins-build/build/workspace/ceph-pull-requests/src/os/bluestore/BlueFS.cc:4679:19
#4 0x55dcd56b0ff5 in BlueFS::mount() /home/jenkins-build/build/workspace/ceph-pull-requests/src/os/bluestore/BlueFS.cc:1129:16
#5 0x55dcd554a97c in BlueFS_test_log_runway_3_Test::TestBody() /home/jenkins-build/build/workspace/ceph-pull-requests/src/test/objectstore/test_bluefs.cc:2185:6
#6 0x55dcd566012d in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /home/jenkins-build/build/workspace/ceph-pull-requests/src/googletest/googletest/src/gtest.cc:2653:10
#7 0x55dcd5622095 in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /home/jenkins-build/build/workspace/ceph-pull-requests/src/googletest/googletest/src/gtest.cc:2689:14
#8 0x55dcd55dcddd in testing::Test::Run() /home/jenkins-build/build/workspace/ceph-pull-requests/src/googletest/googletest/src/gtest.cc:2728:5
```
in this change, we manually umount the BlueFS at the end of testing
to address the leak.
also, we failed to free the created writer, let's free it after using it.
Signed-off-by: Kefu Chai <tchaikov@gmail.com>
5e392f2 to
8acd746
Compare
Contributor
Author
|
jenkins test windows |
Contributor
Author
|
@aclamk hi Adam, could you please help review this change? |
14 tasks
Contributor
Author
|
closing in favor of #63761 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
previously, we mounted BlueFS for testing, but we didn't umount it after done with the testing. the log.writer was leaked this way.
and ASan rightly pointed this out:
in this change, we manually umount the BlueFS at the end of testing to address the leak.
also, we failed to free the created writer, let's free it after using it.
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
xbetween the brackets:[x]. Spaces and capitalization matter when checking off items this way.Checklist
Show available Jenkins commands
jenkins test classic perfJenkins Job | Jenkins Job Definitionjenkins test crimson perfJenkins Job | Jenkins Job Definitionjenkins test signedJenkins Job | Jenkins Job Definitionjenkins test make checkJenkins Job | Jenkins Job Definitionjenkins test make check arm64Jenkins Job | Jenkins Job Definitionjenkins test submodulesJenkins Job | Jenkins Job Definitionjenkins test dashboardJenkins Job | Jenkins Job Definitionjenkins test dashboard cephadmJenkins Job | Jenkins Job Definitionjenkins test apiJenkins Job | Jenkins Job Definitionjenkins test docsReadTheDocs | Github Workflow Definitionjenkins test ceph-volume allJenkins Jobs | Jenkins Jobs Definitionjenkins test windowsJenkins Job | Jenkins Job Definitionjenkins test rook e2eJenkins Job | Jenkins Job Definition