-
Notifications
You must be signed in to change notification settings - Fork 258
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 detected when creating threads in libc++ #819
Comments
Do you see this with r18? |
No, as mentioned above we are using r16. |
I see that, but the bug template states:
We don't backport fixes to old NDKs, so if it doesn't repro on r18 there's nothing for us to fix. |
Thanks, Dan for your response. |
One more update, I have tested the same scenario with gnustl lib and there I am not observing any leak. Test_make_thread.................................................................................................................................................................................................................PASSED Top 3 Slowest Tests SecondsTestFileSetup 00.049647 Test Method ResultsPASSED 2 Detailed logs are available at "f:\stl\Logs\ut.droidx86.debug.log". TESTS PASSED Execution TimesTest Run Time 20 sec f:\stl\dev\liblet\events\test> |
I'm not sure how I'm going to repro it with any NDK release if you don't have a repro case that works outside your environment. I see there's a snippet in the original post, but it's not complete. What test library is that? How is it built? How are you checking for leaks? |
This is our internal test suite. I am not sure how we are checking for leaks but I strongly think that it is being done in a standard way by overloading new, |
Try to reduce a test case if you can. |
I got this link:- http://clang-developers.42468.n3.nabble.com/Libcxx-TizenRT-Memory-leak-in-std-thread-td4060726.html |
I am able to reproduce it even with the one test case. I have added others just to try other scenarios. |
Based on https://github.com/llvm-mirror/libcxx/blob/master/include/thread#L189 (linked directly from that bug), this is an intentional leak. Issue #789 also talks about this. |
template What should we do about it? |
The thread you linked explains the rationale.
And the comment in the code gives another reason: // __thread_specific_ptr is only created with a static storage duration
// so this destructor is only invoked during program termination. Invoking
// pthread_key_delete(__key_) may prevent other threads from deleting their
// thread local data. For this reason we leak the key. Closing since this is intended behavior. |
As for what you can do about it on your end, I'd probably look at whatever method you're using to detect leaks. Probably would also be informative to see how valgrind or some other leak detector behaves with libc++'s std::thread. |
Appreciate you for your efforts and time for investigating this issue. |
Memory leak is detected when we are creating std::thread object.
Our existing test suite has started detecting memory leak where we are creating std::thread object after we moved from gnustl to libc++. Apart from stdlib changes, nothing has changed in our code.
I also wrote a test case which to replicate the issue.
I am seeing this issue during teardown process.
* FAIL:
4 leaks
OAUTOBUGTAG:CLS[DEBUGHEAP_LEAK][4][][][]ENDOABT
Bug reports with better test cases will be resolved sooner than those with bad
test cases. A good test case:
Environment Details
Not all of these will be relevant to every bug, but please provide as much
information as you can.
The text was updated successfully, but these errors were encountered: