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

Memory leak issue in reset() function from boost::thread_specific_ptr #371

Open
HareeshAgraharam opened this issue May 16, 2022 · 0 comments

Comments

@HareeshAgraharam
Copy link

HareeshAgraharam commented May 16, 2022

Following memory leak issue is observed with reset() method from boost::thread_specific_ptr by using valgrind tool in Boost 1.75.

### Leak description:

==27891== 24 bytes in 1 blocks are still reachable in loss record 1 of 2
==27891==    at 0x4835DEF: operator new(unsigned long) (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==27891==    by 0x113064: boost::detail::make_external_thread_data() (in /home/{user}/boost_1_75_0/a.out)
==27891==    by 0x114084: boost::detail::add_new_tss_node(void const*, void (*)(void (*)(void*), void*), void (*)(void*), void*) (in /home/{user}/boost_1_75_0/a.out)
==27891==    by 0x1102F5: boost::thread_specific_ptr<int>::reset(int*) (in /home/{user}/boost_1_75_0/a.out)
==27891==    by 0x10DC07: main (in /home/{user}/boost_1_75_0/a.out)

Code Snippet:

#include <boost/thread.hpp>
#include <iostream>
int main()
{
	boost::thread_specific_ptr<int> conv_thread_ptr;
	if(!conv_thread_ptr.get())
	{
        	conv_thread_ptr.reset(new int);
	}
	return 0;
}

Command used for compilation:
g++ main.cpp -I./boost_1_75_0_install/include ./boost_1_75_0_install/lib/libboost_thread.a -lpthread

Command used for memory leak checking with valgrind:
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose --log-file=valgrind-out.txt ./a.out

@vaishnavkatiyar

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

1 participant