Open Bug 1894540 Opened 17 days ago Updated 15 days ago

Permanent ThreadSanitizer GTest thread leak nsprpub/pr/src/pthreads/ptthread.c:458:14 in _PR_CreateThread

Categories

(Core :: XPCOM, defect)

defect

Tracking

()

People

(Reporter: RyanVM, Unassigned)

References

Details

Seems to happen at the end of the run after tests all finish. Not cleaning up properly? But most importantly, this basically means we can't disable our way to victory to get this suite enabled in CI unless it can be tied back to an earlier-run test.

ThreadSanitizer thread leak nsprpub/pr/src/pthreads/ptthread.c:458:14 in _PR_CreateThread
https://treeherder.mozilla.org/logviewer?job_id=456566709&repo=try&lineNumber=392528

TEST-PASS | GTest unit test: passed
Passed: 7198
Failed: 0
console.trace: Places - FrecencyRecalculator: "Finalizing frecency recalculator"
resource://gre/modules/PlacesFrecencyRecalculator.sys.mjs 189 #finalize
resource://gre/modules/PlacesFrecencyRecalculator.sys.mjs 130 PlacesFrecencyRecalculator/<
resource://gre/modules/AsyncShutdown.sys.mjs 754 trigger
resource://gre/modules/AsyncShutdown.sys.mjs 914 _wait
resource://gre/modules/AsyncShutdown.sys.mjs 895 wait
resource://gre/modules/AsyncShutdown.sys.mjs 554 observe
[ERROR glean_core::database] Failed to record metric 'dirtybit' into glean_internal_info: Error { kind: Rkv(IoError(Os { code: 2, kind: NotFound, message: "No such file or directory" })) }
[ERROR glean_core] Can't persist ping lifetime data: Error { kind: Rkv(IoError(Os { code: 2, kind: NotFound, message: "No such file or directory" })) }
Finished running GTest tests.
==================
WARNING: ThreadSanitizer: thread leak (pid=987)
  Thread T40756 ' #1,SHDRCV' (tid=9715, finished) created by main thread at:
    #0 pthread_create /fetches/llvm-project/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp:1020:3 (firefox-bin+0xc59bb)
    #1 _PR_CreateThread /checkouts/gecko/nsprpub/pr/src/pthreads/ptthread.c:458:14 (libnspr4.so+0x42cee)
    #2 PR_CreateThread /checkouts/gecko/nsprpub/pr/src/pthreads/ptthread.c:533:12 (libnspr4.so+0x37f84)
    #3 nsThread::Init(nsTSubstring<char> const&) /checkouts/gecko/xpcom/threads/nsThread.cpp:620:20 (libxul.so+0x54f8657)
    #4 nsThreadManager::NewNamedThread(nsTSubstring<char> const&, nsIThreadManager::ThreadCreationOptions, nsIThread**) /checkouts/gecko/xpcom/threads/nsThreadManager.cpp:602:22 (libxul.so+0x55006fd)
    #5 NS_NewNamedThread(nsTSubstring<char> const&, nsIThread**, already_AddRefed<nsIRunnable>, nsIThreadManager::ThreadCreationOptions) /checkouts/gecko/xpcom/threads/nsThreadUtils.cpp:176:57 (libxul.so+0x55093b3)
    #6 NS_NewNamedThread /checkouts/gecko/xpcom/threads/nsThreadUtils.cpp:168:10 (libxul.so+0x55036cb)
    #7 nsThreadPool::PutEvent(already_AddRefed<nsIRunnable>, unsigned int) /checkouts/gecko/xpcom/threads/nsThreadPool.cpp:126:17 (libxul.so+0x55036cb)
    #8 Dispatch /checkouts/gecko/xpcom/threads/nsThreadPool.cpp:379:3 (libxul.so+0x5505113)
    #9 non-virtual thunk to nsThreadPool::Dispatch(already_AddRefed<nsIRunnable>, unsigned int) /checkouts/gecko/xpcom/threads/nsThreadPool.cpp (libxul.so+0x5505113)
    #10 Dispatch /workspace/obj-build/dist/include/nsIEventTarget.h:38:14 (libxul.so+0x3a8f315)
    #11 ThreadPool_ShutdownWithTimeout_Test::TestBody() /checkouts/gecko/xpcom/tests/gtest/TestThreadPool.cpp:148:11 (libxul.so+0x3a8f315)
    #12 void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /checkouts/gecko/third_party/googletest/googletest/src/gtest.cc (libxul.so+0x424a3ed)
    #13 testing::Test::Run() /checkouts/gecko/third_party/googletest/googletest/src/gtest.cc:2688:5 (libxul.so+0x424a259)
    #14 testing::TestInfo::Run() /checkouts/gecko/third_party/googletest/googletest/src/gtest.cc:2837:11 (libxul.so+0x424bc68)
    #15 testing::TestSuite::Run() /checkouts/gecko/third_party/googletest/googletest/src/gtest.cc:3016:30 (libxul.so+0x424d264)
    #16 testing::internal::UnitTestImpl::RunAllTests() /checkouts/gecko/third_party/googletest/googletest/src/gtest.cc:5922:44 (libxul.so+0x426acf9)
    #17 bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) /checkouts/gecko/third_party/googletest/googletest/src/gtest.cc (libxul.so+0x426a49d)
    #18 testing::UnitTest::Run() /checkouts/gecko/third_party/googletest/googletest/src/gtest.cc:5486:10 (libxul.so+0x426a240)
    #19 RUN_ALL_TESTS /workspace/obj-build/dist/include/gtest/gtest.h:2319:73 (libxul.so+0x421fbff)
    #20 mozilla::RunGTestFunc(int*, char**) /checkouts/gecko/testing/gtest/mozilla/GTestRunner.cpp:167:10 (libxul.so+0x421fbff)
    #21 XREMain::XRE_mainStartup(bool*) /checkouts/gecko/toolkit/xre/nsAppRunner.cpp:4686:16 (libxul.so+0xbf99fe9)
    #22 XREMain::XRE_main(int, char**, mozilla::BootstrapConfig const&) /checkouts/gecko/toolkit/xre/nsAppRunner.cpp:5946:12 (libxul.so+0xbfa1d12)
    #23 XRE_main(int, char**, mozilla::BootstrapConfig const&) /checkouts/gecko/toolkit/xre/nsAppRunner.cpp:6015:21 (libxul.so+0xbfa2451)
    #24 mozilla::BootstrapImpl::XRE_main(int, char**, mozilla::BootstrapConfig const&) /checkouts/gecko/toolkit/xre/Bootstrap.cpp:45:12 (libxul.so+0xbfb14a2)
    #25 do_main /checkouts/gecko/browser/app/nsBrowserApp.cpp:227:22 (firefox-bin+0x14ea00)
    #26 main /checkouts/gecko/browser/app/nsBrowserApp.cpp:445:16 (firefox-bin+0x14ea00)
SUMMARY: ThreadSanitizer: thread leak /checkouts/gecko/nsprpub/pr/src/pthreads/ptthread.c:458:14 in _PR_CreateThread

The stack has ThreadPool_ShutdownWithTimeout_Test in it. Could it be due to that test? Or is this just an example and it shows up differently otherwise?

Good spot, that test does indeed look like the culprit!

We should probably suppress the particular signature for when we intentionally leak the thread . We're running into this in the ShutdownWithTimeout tests because of intentional behavior. The leaked thread is never joined.

Severity: -- → S3

Here is a page on the TSan suppressions.

FYI, you'll need to revert the below change to re-enable the test when there's a fix ready.
https://hg.mozilla.org/mozilla-central/diff/8ceeacec0dfd1398a7cc01d1b5a08ae5be835435/xpcom/tests/gtest/moz.build

You need to log in before you can comment on or make changes to this bug.