Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XrdBuffManager leaks memory #424

Closed
gbitzes opened this issue Oct 12, 2016 · 3 comments
Closed

XrdBuffManager leaks memory #424

gbitzes opened this issue Oct 12, 2016 · 3 comments
Assignees

Comments

@gbitzes
Copy link
Contributor

gbitzes commented Oct 12, 2016

Hi,

There's this note in the destructor of XrdBuffManager:

           ~XrdBuffManager() {} // The buffmanager is never deleted

My unit tests for quarkdb involve lots of request parsing, which uses XrdBuffManager internally for memory recycling. Every unit test is independent of each other, meaning it sets up its own XrdBuffManager which gets deleted at the end, but the buffers are not freed.. This makes running a leak detector difficult, since at the end I get a ton of such messages:

Direct leak of 432 byte(s) in 18 object(s) allocated from:
    #0 0x7fbc8611bb62 in operator new(unsigned long) (/home/geobijes/dev/quarkdb/build/src/libXrdRedis.so+0x240b62)
    #1 0x7fbc85cb08be in XrdBuffManager::Obtain(int) /home/geobijes/dev/xrootd/src/Xrd/XrdBuffer.cc:169
    #2 0x7fbc8606d1e0 in quarkdb::BufferedReader::BufferedReader(quarkdb::Link*, XrdBuffManager*, unsigned long) /home/geobijes/dev/quarkdb/src/BufferedReader.cc:33
    #3 0x7fbc8606ecc2 in quarkdb::RedisParser::RedisParser(quarkdb::Link*, XrdBuffManager*) /home/geobijes/dev/quarkdb/src/RedisParser.cc:28
    #4 0x7fbc86085dd7 in quarkdb::Poller::worker(int, quarkdb::Dispatcher*) /home/geobijes/dev/quarkdb/src/Poller.cc:60
    #5 0x7fbc86089e43 in void std::_Mem_fn_base<void (quarkdb::Poller::*)(int, quarkdb::Dispatcher*), true>::operator()<int, quarkdb::Dispatcher*, void>(quarkdb::Poller*, int&&, quarkdb::Dispatcher*&&) const /usr/include/c++/5/functional:600
    #6 0x7fbc86089ca2 in void std::_Bind_simple<std::_Mem_fn<void (quarkdb::Poller::*)(int, quarkdb::Dispatcher*)> (quarkdb::Poller*, int, quarkdb::Dispatcher*)>::_M_invoke<0ul, 1ul, 2ul>(std::_Index_tuple<0ul, 1ul, 2ul>) /usr/include/c++/5/functional:1531
    #7 0x7fbc86089a8f in std::_Bind_simple<std::_Mem_fn<void (quarkdb::Poller::*)(int, quarkdb::Dispatcher*)> (quarkdb::Poller*, int, quarkdb::Dispatcher*)>::operator()() /usr/include/c++/5/functional:1520
    #8 0x7fbc860899bf in std::thread::_Impl<std::_Bind_simple<std::_Mem_fn<void (quarkdb::Poller::*)(int, quarkdb::Dispatcher*)> (quarkdb::Poller*, int, quarkdb::Dispatcher*)> >::_M_run() /usr/include/c++/5/thread:115
    #9 0x7fbc85767c7f  (/usr/lib/x86_64-linux-gnu/libstdc++.so.6+0xb8c7f)

This might be worth fixing, if only to make the use of leak detectors more pleasant.

@abh3
Copy link
Member

abh3 commented Oct 13, 2016

We could do that but it still wouldn't be able to free any buffers that
were handed out (and not yet returned) so you will still get lost memory
messages at the end. Is that still acceptable?

Andy

On Wed, 12 Oct 2016, Georgios Bitzes wrote:

Hi,

There's this note in the destructor of XrdBuffManager:

          ~XrdBuffManager() {} // The buffmanager is never deleted

My unit tests for quarkdb involve lots of request parsing, which uses XrdBuffManager internally for memory recycling. Every unit test is independent of each other, meaning it sets up its own XrdBuffManager which gets deleted at the end, but the buffers are not freed.. This makes running a leak detector difficult, since at the end I get a ton of such messages:

Direct leak of 432 byte(s) in 18 object(s) allocated from:
   #0 0x7fbc8611bb62 in operator new(unsigned long) (/home/geobijes/dev/quarkdb/build/src/libXrdRedis.so+0x240b62)
   #1 0x7fbc85cb08be in XrdBuffManager::Obtain(int) /home/geobijes/dev/xrootd/src/Xrd/XrdBuffer.cc:169
   #2 0x7fbc8606d1e0 in quarkdb::BufferedReader::BufferedReader(quarkdb::Link*, XrdBuffManager*, unsigned long) /home/geobijes/dev/quarkdb/src/BufferedReader.cc:33
   #3 0x7fbc8606ecc2 in quarkdb::RedisParser::RedisParser(quarkdb::Link*, XrdBuffManager*) /home/geobijes/dev/quarkdb/src/RedisParser.cc:28
   #4 0x7fbc86085dd7 in quarkdb::Poller::worker(int, quarkdb::Dispatcher*) /home/geobijes/dev/quarkdb/src/Poller.cc:60
   #5 0x7fbc86089e43 in void std::_Mem_fn_base<void (quarkdb::Poller::*)(int, quarkdb::Dispatcher*), true>::operator()<int, quarkdb::Dispatcher*, void>(quarkdb::Poller*, int&&, quarkdb::Dispatcher*&&) const /usr/include/c++/5/functional:600
   #6 0x7fbc86089ca2 in void std::_Bind_simple<std::_Mem_fn<void (quarkdb::Poller::*)(int, quarkdb::Dispatcher*)> (quarkdb::Poller*, int, quarkdb::Dispatcher*)>::_M_invoke<0ul, 1ul, 2ul>(std::_Index_tuple<0ul, 1ul, 2ul>) /usr/include/c++/5/functional:1531
   #7 0x7fbc86089a8f in std::_Bind_simple<std::_Mem_fn<void (quarkdb::Poller::*)(int, quarkdb::Dispatcher*)> (quarkdb::Poller*, int, quarkdb::Dispatcher*)>::operator()() /usr/include/c++/5/functional:1520
   #8 0x7fbc860899bf in std::thread::_Impl<std::_Bind_simple<std::_Mem_fn<void (quarkdb::Poller::*)(int, quarkdb::Dispatcher*)> (quarkdb::Poller*, int, quarkdb::Dispatcher*)> >::_M_run() /usr/include/c++/5/thread:115
   #9 0x7fbc85767c7f  (/usr/lib/x86_64-linux-gnu/libstdc++.so.6+0xb8c7f)

This might be worth fixing, if only to make the use of leak detectors more pleasant.

You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
#424

@gbitzes
Copy link
Contributor Author

gbitzes commented Oct 13, 2016

Hi Andy,

Yes, of course that's acceptable. If the buffers are not eventually released back to the pool, and not free'd manually, that's probably a bug of the user of the class, and a valid case of a memory leak to be reported.

@abh3 abh3 self-assigned this Jan 20, 2017
@abh3
Copy link
Member

abh3 commented Jan 20, 2017

Fixed in 4.6.

@abh3 abh3 closed this as completed Jan 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants