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

[BUG] sporadic memory leak (reported by valgrind) #606

Open
mroland91 opened this issue Nov 7, 2024 · 3 comments
Open

[BUG] sporadic memory leak (reported by valgrind) #606

mroland91 opened this issue Nov 7, 2024 · 3 comments

Comments

@mroland91
Copy link

Describe the bug
When I am running tests for my app which uses redis-plus-plus, sometimes valgrind reports memory leak. The trace is the same every time (run into this around 5-8 times).

==6664== Memcheck, a memory error detector

==6664== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.

==6664== Using Valgrind-3.19.0 and LibVEX; rerun with -h for copyright info

==6664== Command: /home/test/redis-client

==6664== Parent PID: 6663

==6664==

==6664==

==6664== HEAP SUMMARY:

==6664== in use at exit: 21,237 bytes in 32 blocks

==6664== total heap usage: 61,639 allocs, 61,607 frees, 7,818,347 bytes allocated

==6664==

==6664== 2,224 (400 direct, 1,824 indirect) bytes in 1 blocks are definitely lost in loss record 23 of 24

==6664== at 0x4C398C3: operator new(unsigned long) (vg_replace_malloc.c:422)

==6664== by 0x6CB7522: __gnu_cxx::new_allocator<std::_Sp_counted_ptr_inplace<sw::redis::AsyncConnection, std::allocatorsw::redis::AsyncConnection, (__gnu_cxx::_Lock_policy)2> >::allocate(unsigned long, void const*) (in /usr/lib64/libredis++.so.1.3.12)

==6664== by 0x6CB6FAA: std::allocator_traits<std::allocator<std::_Sp_counted_ptr_inplace<sw::redis::AsyncConnection, std::allocatorsw::redis::AsyncConnection, (__gnu_cxx::_Lock_policy)2> > >::allocate(std::allocator<std::_Sp_counted_ptr_inplace<sw::redis::AsyncConnection, std::allocatorsw::redis::AsyncConnection, (__gnu_cxx::_Lock_policy)2> >&, unsigned long) (in /usr/lib64/libredis++.so.1.3.12)

==6664== by 0x6CB6709: std::__allocated_ptr<std::allocator<std::_Sp_counted_ptr_inplace<sw::redis::AsyncConnection, std::allocatorsw::redis::AsyncConnection, (__gnu_cxx::_Lock_policy)2> > > std::__allocate_guarded<std::allocator<std::_Sp_counted_ptr_inplace<sw::redis::AsyncConnection, std::allocatorsw::redis::AsyncConnection, (__gnu_cxx::_Lock_policy)2> > >(std::allocator<std::_Sp_counted_ptr_inplace<sw::redis::AsyncConnection, std::allocatorsw::redis::AsyncConnection, (__gnu_cxx::_Lock_policy)2> >&) (in /usr/lib64/libredis++.so.1.3.12)

==6664== by 0x6CB61E5: std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<sw::redis::AsyncConnection, std::allocatorsw::redis::AsyncConnection, sw::redis::ConnectionOptions&, sw::redis::EventLoop*>(sw::redis::AsyncConnection*&, std::_Sp_alloc_shared_tag<std::allocatorsw::redis::AsyncConnection >, sw::redis::ConnectionOptions&, sw::redis::EventLoop*&&) (in /usr/lib64/libredis++.so.1.3.12)

==6664== by 0x6CB5B0B: std::__shared_ptr<sw::redis::AsyncConnection, (__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocatorsw::redis::AsyncConnection, sw::redis::ConnectionOptions&, sw::redis::EventLoop*>(std::_Sp_alloc_shared_tag<std::allocatorsw::redis::AsyncConnection >, sw::redis::ConnectionOptions&, sw::redis::EventLoop*&&) (in /usr/lib64/libredis++.so.1.3.12)

==6664== by 0x6CB55B6: std::shared_ptrsw::redis::AsyncConnection::shared_ptr<std::allocatorsw::redis::AsyncConnection, sw::redis::ConnectionOptions&, sw::redis::EventLoop*>(std::_Sp_alloc_shared_tag<std::allocatorsw::redis::AsyncConnection >, sw::redis::ConnectionOptions&, sw::redis::EventLoop*&&) (in /usr/lib64/libredis++.so.1.3.12)

==6664== by 0x6CB4CF3: std::shared_ptrsw::redis::AsyncConnection std::allocate_shared<sw::redis::AsyncConnection, std::allocatorsw::redis::AsyncConnection, sw::redis::ConnectionOptions&, sw::redis::EventLoop*>(std::allocatorsw::redis::AsyncConnection const&, sw::redis::ConnectionOptions&, sw::redis::EventLoop*&&) (in /usr/lib64/libredis++.so.1.3.12)

==6664== by 0x6CB4567: std::shared_ptrsw::redis::AsyncConnection std::make_shared<sw::redis::AsyncConnection, sw::redis::ConnectionOptions&, sw::redis::EventLoop*>(sw::redis::ConnectionOptions&, sw::redis::EventLoop*&&) (in /usr/lib64/libredis++.so.1.3.12)

==6664== by 0x6CB3314: sw::redis::AsyncConnectionPool::_create() (in /usr/lib64/libredis++.so.1.3.12)

==6664== by 0x6CB24DB: sw::redis::AsyncConnectionPool::fetch() (in /usr/lib64/libredis++.so.1.3.12)

==6664== by 0x6CAF4D1: sw::redis::GuardedAsyncConnection::GuardedAsyncConnection(std::shared_ptrsw::redis::AsyncConnectionPool const&) (in /usr/lib64/libredis++.so.1.3.12)

==6664==

==6664== LEAK SUMMARY:

==6664== definitely lost: 400 bytes in 1 blocks

==6664== indirectly lost: 1,824 bytes in 22 blocks

==6664== possibly lost: 384 bytes in 1 blocks

==6664== still reachable: 18,629 bytes in 8 blocks

==6664== suppressed: 0 bytes in 0 blocks

==6664== Reachable blocks (those to which a pointer was found) are not shown.

==6664== To see them, rerun with: --leak-check=full --show-leak-kinds=all

==6664==

==6664== For lists of detected and suppressed errors, rerun with: -s

==6664== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

To Reproduce
sporadic

Expected behavior
no report from valgrind

Environment:

  • OS: Rocky Linux
  • Compiler: gcc 8.5.0
  • hiredis version: 1.0.2
  • redis-plus-plus version: 1.3.2
@sewenew
Copy link
Owner

sewenew commented Nov 8, 2024

This might be a duplicated issue to #543 which has been fixed. You can test it with the latest code.

Regards

@mroland91
Copy link
Author

I'm using 1.3.12 which contains that fix.

@sewenew
Copy link
Owner

sewenew commented Nov 14, 2024

Can you give a minimum code snippet that can reproduce the problem? Thanks!

Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants