Closed Bug 1887870 Opened 2 years ago Closed 2 years ago

ThreadSanitizer: CHECK failed: sanitizer_deadlock_detector.h:67 "((n_all_locks_)) < (((sizeof(all_locks_with_contexts_)/sizeof((all_locks_with_contexts_)[0]))))

Categories

(Core :: IPC, defect)

defect

Tracking

()

RESOLVED FIXED
126 Branch
Tracking Status
firefox126 --- fixed

People

(Reporter: whimboo, Assigned: nika)

References

(Blocks 1 open bug)

Details

Attachments

(1 external file)

For an upcoming change of the runner for web-platform test (see bug 1522790) we are going to move the logic for opening a new browser tab from running window.open() via script execution to the WebDriver command WebDriver:NewWindow. With that change applied TSAN only test jobs are failing because of external timeouts of the runner. This happens permanently for the test /FileAPI/url/url-format.any.worker.html, which gets constructed via /FileAPI/url/url-format.any.js.

The failure / error can be seen at:
https://treeherder.mozilla.org/logviewer?job_id=452196537&repo=try&lineNumber=2157-2170

[task 2024-03-25T17:06:32.748Z] 17:06:32     INFO - PID 984 | 1711386392747	Marionette	INFO	*** navigation timeout: 90000ms
[task 2024-03-25T17:06:32.769Z] 17:06:32     INFO - PID 984 | 1711386392768	Marionette	TRACE	[15] Received event beforeunload for about:blank
[task 2024-03-25T17:06:32.774Z] 17:06:32     INFO - PID 984 | [Parent 984: Main Thread]: I/BCWebProgress OnStateChange({isTopLevel:1, isLoadingDocument:0}, {URI:http://web-platform.test:8000/FileAPI/url/url-format.any.worker.html, originalURI:http://web-platform.test:8000/FileAPI/url/url-format.any.worker.html}, STATE_START|STATE_IS_REQUEST|STATE_IS_DOCUMENT|STATE_IS_NETWORK|STATE_IS_WINDOW, NS_OK) on {top:1, id:f, url:about:blank}
[task 2024-03-25T17:06:32.828Z] 17:06:32     INFO - wptserve GET /FileAPI/url/url-format.any.worker.html
[task 2024-03-25T17:06:32.828Z] 17:06:32     INFO - wptserve Found handler WorkersHandler
[task 2024-03-25T17:06:32.828Z] 17:06:32     INFO - wptserve 200 GET /FileAPI/url/url-format.any.worker.html (None) 0
[task 2024-03-25T17:06:32.915Z] 17:06:32     INFO - PID 984 | 1711386392914	Marionette	TRACE	Remoteness change detected. Set new top-level browsing context to 16
[task 2024-03-25T17:06:32.936Z] 17:06:32     INFO - PID 984 | [Parent 984: Main Thread]: I/BCWebProgress OnStatusChange({isTopLevel:1, isLoadingDocument:1}, {URI:http://web-platform.test:8000/FileAPI/url/url-format.any.worker.html, originalURI:http://web-platform.test:8000/FileAPI/url/url-format.any.worker.html}, NS_NET_STATUS_WAITING_FOR, "web-platform.test") on {top:1, id:10, url:about:blank}
[task 2024-03-25T17:06:33.091Z] 17:06:33     INFO - PID 984 | 1711386393090	Marionette	TRACE	[16] Received event beforeunload for about:blank
[task 2024-03-25T17:06:33.097Z] 17:06:33     INFO - PID 984 | [Parent 984: Main Thread]: I/BCWebProgress OnStateChange({isTopLevel:1, isLoadingDocument:1}, {URI:http://web-platform.test:8000/FileAPI/url/url-format.any.worker.html, originalURI:http://web-platform.test:8000/FileAPI/url/url-format.any.worker.html}, STATE_START|STATE_IS_REQUEST|STATE_IS_DOCUMENT|STATE_IS_NETWORK|STATE_IS_WINDOW, NS_OK) on {top:1, id:10, url:about:blank}
[task 2024-03-25T17:06:35.768Z] 17:06:35     INFO - PID 984 | ThreadSanitizer: CHECK failed: sanitizer_deadlock_detector.h:67 "((n_all_locks_)) < (((sizeof(all_locks_with_contexts_)/sizeof((all_locks_with_contexts_)[0]))))" (0x40, 0x40) (tid=984)
[task 2024-03-25T17:09:46.026Z] 17:09:46     INFO - Got timeout in harness
[task 2024-03-25T17:09:46.028Z] 17:09:46     INFO - TEST-UNEXPECTED-TIMEOUT | /FileAPI/url/url-format.any.worker.html | TestRunner hit external timeout (this may indicate a hang)
[task 2024-03-25T17:09:46.029Z] 17:09:46     INFO - TEST-INFO took 195004ms

The related changes are only in Python code which means that we hit a case that isn't utilized yet. It's not clear what this error actually means, especially because no stacktrace is available.

For testing purposes I've added another navigation to the live site first:
https://treeherder.mozilla.org/logviewer?job_id=452366112&repo=try&lineNumber=1563-1582

As it can be seen this navigation works just fine, while the one to our local server is triggering the issue. I'll try to reduce as much content from the test page as I can to see what specifically triggers it.

After removing some tests from that file I can see that the sanitizer deadlock only happens when the following test is run:

https://searchfox.org/mozilla-central/rev/7bbc54b70e348a11f9cd12071ada2cb47c8a14e3/testing/web-platform/tests/FileAPI/url/url-format.any.js#5-22

test(t => {
  const url_count = 5000;
  let list = [];

  t.add_cleanup(() => {
    for (let url of list) {
      URL.revokeObjectURL(url);
    }
  });

  for (let i = 0; i < url_count; ++i)
    list.push(URL.createObjectURL(blob));

  list.sort();

  for (let i = 1; i < list.length; ++i)
    assert_not_equals(list[i], list[i-1], 'generated Blob URLs should be unique');
}, 'Generated Blob URLs are unique');

I reduced the test further and it's actually a problem with URL.createObjectURL with a Blob instance that gets called 5000 times:

const blob = new Blob(['test']);

test(t => {
  const url_count = 5000;
  let list = [];

  for (let i = 0; i < url_count; ++i)
    list.push(URL.createObjectURL(blob));
}, 'Generated Blob URLs are unique');

There is a discussion about this deadlock over on:
https://groups.google.com/g/thread-sanitizer/c/kbStiqIGVLA/m/QbMLM3e8CAAJ

This CHECK fires when a thread tries to acquire more than 64 mutexes
recursively (one under another). Are you sure that you don't leak
locked mutexes? Maybe you forget to unlock a mutex somewhere? 

There is also a patch proposed to get further details when this issue occurs. But it seems that I would have to patch llvm and then submit it as part of the push to try. Not sure how this can be done.

Glandium, do you maybe have some advice?

CC glandium for the last comment given that I cannot set needinfo for him.

With the following try push I reduced the amount of iterations to just 64 to see if that fails as well (based on the above comment) and it actually does:

https://treeherder.mozilla.org/jobs?repo=try&revision=f4fc119f4fa4e3197a51de5e40ae7e5232312825&selectedTaskRun=e7uG1gowSg6ulqxPOVGXVw.0

But using just 50 iterations makes the test pass:

https://treeherder.mozilla.org/jobs?repo=try&revision=74532cf522952762aa2d2113c142b3558cf26fbf&selectedTaskRun=SUL5Lmh4Ti-DANhUOuCT_g.0

Sunil, could this be an issue with mutexes in the implementation for URL.createObjectURL()?

Flags: needinfo?(smayya)

(In reply to Henrik Skupin [:whimboo][⌚️UTC+1] from comment #4)

There is a discussion about this deadlock over on:
https://groups.google.com/g/thread-sanitizer/c/kbStiqIGVLA/m/QbMLM3e8CAAJ

This CHECK fires when a thread tries to acquire more than 64 mutexes
recursively (one under another). Are you sure that you don't leak
locked mutexes? Maybe you forget to unlock a mutex somewhere? 

There is also a patch proposed to get further details when this issue occurs. But it seems that I would have to patch llvm and then submit it as part of the push to try. Not sure how this can be done.

Glandium, do you maybe have some advice?

Given that the needinfo request didn't work last week let me try it again. Would such a patch for llvm still help us to find the cause?

Flags: needinfo?(mh+mozilla)

Considering how old the patch is, here's what you should do:

Flags: needinfo?(mh+mozilla)
Blocks: tsan

After discussing with Olli here some more details / speculations:

  • The failing ThreadSanitizer check happens in the parent and not content process
  • Adding dump() calls to the test for printing the index works fine until the test reaches 63 blob URL objects. Then with 64 not a single dump is printed to the logs. Not sure how this correlates with the This CHECK fires when a thread tries to acquire more than 64 mutexes recursively statement from above. But at least it is close to that.
  • Maybe this could be some IPC issue, but Smaug checked a locally created profile with IPC messages enabled and he didn't notice an issue on first sight. He would have to check maybe a second time.
No longer blocks: tsan

(In reply to Mike Hommey [:glandium] from comment #8)

Considering how old the patch is, here's what you should do:

Thanks a lot! It was easy to find the related code and to extract a patch from it. Lets see if building llvm with the patch applied works fine in CI and gives us more insight. Here is the try build:

https://treeherder.mozilla.org/jobs?repo=try&revision=40dd44d836aecea75bde3b6bf6ce2e6cb048f197

Blocks: tsan

And we now have stacks:
https://treeherder.mozilla.org/logviewer?job_id=453295255&repo=try&lineNumber=1899-1953

INFO - PID 984 | Current thread holds too many mutexes
INFO - PID 984 |     #0 __libc_start_main /tmp/glibc/csu/../csu/libc-start.c:310 (libc.so.6+0x21b96) (BuildId: 3247775c25514939b9a5ffa9d3be63f3a4cb9641)
INFO - PID 984 |     #1 do_main /builds/worker/checkouts/gecko/browser/app/nsBrowserApp.cpp:227:22 (firefox-bin+0x14ea60) (BuildId: 86f8757bf323fdb2d18d9f480e442f873a859b7a)
INFO - PID 984 |     #2 main /builds/worker/checkouts/gecko/browser/app/nsBrowserApp.cpp:445:16 (firefox-bin+0x14ea60)
INFO - PID 984 |     #3 mozilla::BootstrapImpl::XRE_main(int, char**, mozilla::BootstrapConfig const&) /builds/worker/checkouts/gecko/toolkit/xre/Bootstrap.cpp:45:12 (libxul.so+0xb2b30a2) (BuildId: 9410836837796488cc9bde3201fbd997d21da338)
INFO - PID 984 |     #4 XRE_main(int, char**, mozilla::BootstrapConfig const&) /builds/worker/checkouts/gecko/toolkit/xre/nsAppRunner.cpp:6015:21 (libxul.so+0xb2a3941) (BuildId: 9410836837796488cc9bde3201fbd997d21da338)
INFO - PID 984 |     #5 XREMain::XRE_main(int, char**, mozilla::BootstrapConfig const&) /builds/worker/checkouts/gecko/toolkit/xre/nsAppRunner.cpp:5958:8 (libxul.so+0xb2a3290) (BuildId: 9410836837796488cc9bde3201fbd997d21da338)
INFO - PID 984 |     #6 XREMain::XRE_mainRun() /builds/worker/checkouts/gecko/toolkit/xre/nsAppRunner.cpp:5746:22 (libxul.so+0xb2a2630) (BuildId: 9410836837796488cc9bde3201fbd997d21da338)
INFO - PID 984 |     #7 nsAppStartup::Run() /builds/worker/checkouts/gecko/toolkit/components/startup/nsAppStartup.cpp:296:30 (libxul.so+0xb1175d2) (BuildId: 9410836837796488cc9bde3201fbd997d21da338)
INFO - PID 984 |     #8 nsAppShell::Run() /builds/worker/checkouts/gecko/widget/gtk/nsAppShell.cpp:470:33 (libxul.so+0x8dd85ac) (BuildId: 9410836837796488cc9bde3201fbd997d21da338)
INFO - PID 984 |     #9 nsBaseAppShell::Run() /builds/worker/checkouts/gecko/widget/nsBaseAppShell.cpp:148:27 (libxul.so+0x8cd7c43) (BuildId: 9410836837796488cc9bde3201fbd997d21da338)
INFO - PID 984 |     #10 RunInternal /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:370:10 (libxul.so+0x45991a8) (BuildId: 9410836837796488cc9bde3201fbd997d21da338)
INFO - PID 984 |     #11 RunHandler /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:363:3 (libxul.so+0x45991a8)
INFO - PID 984 |     #12 MessageLoop::Run() /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:345:3 (libxul.so+0x45991a8)
INFO - PID 984 |     #13 mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) /builds/worker/checkouts/gecko/ipc/glue/MessagePump.cpp:85:21 (libxul.so+0x46888de) (BuildId: 9410836837796488cc9bde3201fbd997d21da338)
INFO - PID 984 |     #14 NS_ProcessNextEvent(nsIThread*, bool) /builds/worker/checkouts/gecko/xpcom/threads/nsThreadUtils.cpp:480:10 (libxul.so+0x395b774) (BuildId: 9410836837796488cc9bde3201fbd997d21da338)
INFO - PID 984 |     #15 nsThread::ProcessNextEvent(bool, bool*) /builds/worker/checkouts/gecko/xpcom/threads/nsThread.cpp:1222:3 (libxul.so+0x3954fbf) (BuildId: 9410836837796488cc9bde3201fbd997d21da338)
INFO - PID 984 |     #16 nsThread::DrainDirectTasks() /builds/worker/checkouts/gecko/xpcom/threads/nsThread.cpp:1397:16 (libxul.so+0x3955e6e) (BuildId: 9410836837796488cc9bde3201fbd997d21da338)
INFO - PID 984 |     #17 mozilla::SimpleTaskQueue::DrainTasks() /builds/worker/workspace/obj-build/dist/include/mozilla/TaskDispatcher.h:44:10 (libxul.so+0x3932e01) (BuildId: 9410836837796488cc9bde3201fbd997d21da338)
INFO - PID 984 |     #18 mozilla::MozPromise<nsresult, mozilla::ipc::ResponseRejectReason, true>::ThenValueBase::ResolveOrRejectRunnable::Run() /builds/worker/workspace/obj-build/dist/include/mozilla/MozPromise.h:487:21 (libxul.so+0x43c9935) (BuildId: 9410836837796488cc9bde3201fbd997d21da338)
INFO - PID 984 |     #19 mozilla::MozPromise<nsresult, mozilla::ipc::ResponseRejectReason, true>::ThenValueBase::DoResolveOrReject(mozilla::MozPromise<nsresult, mozilla::ipc::ResponseRejectReason, true>::ResolveOrRejectValue&) /builds/worker/workspace/obj-build/dist/include/mozilla/MozPromise.h:620:7 (libxul.so+0x43ca131) (BuildId: 9410836837796488cc9bde3201fbd997d21da338)
INFO - PID 984 |     #20 operator() /builds/worker/checkouts/gecko/netwerk/ipc/DocumentLoadListener.cpp:2303:19 (libxul.so+0x43d55aa) (BuildId: 9410836837796488cc9bde3201fbd997d21da338)
INFO - PID 984 |     #21 InvokeMethod<(lambda at /builds/worker/checkouts/gecko/netwerk/ipc/DocumentLoadListener.cpp:2294:11), void ((lambda at /builds/worker/checkouts/gecko/netwerk/ipc/DocumentLoadListener.cpp:2294:11)::*)(const nsresult &), nsresult> /builds/worker/workspace/obj-build/dist/include/mozilla/MozPromise.h:651:12 (libxul.so+0x43d55aa)
INFO - PID 984 |     #22 InvokeCallbackMethod<false, (lambda at /builds/worker/checkouts/gecko/netwerk/ipc/DocumentLoadListener.cpp:2294:11), void ((lambda at /builds/worker/checkouts/gecko/netwerk/ipc/DocumentLoadListener.cpp:2294:11)::*)(const nsresult &), nsresult, RefPtr<mozilla::MozPromise<nsresult, mozilla::ipc::ResponseRejectReason, true>::Private> > /builds/worker/workspace/obj-build/dist/include/mozilla/MozPromise.h:682:5 (libxul.so+0x43d55aa)
INFO - PID 984 |     #23 mozilla::MozPromise<nsresult, mozilla::ipc::ResponseRejectReason, true>::ThenValue<mozilla::net::DocumentLoadListener::TriggerRedirectToRealChannel(mozilla::Maybe<mozilla::dom::ContentParent*> const&, nsTArray<mozilla::net::StreamFilterRequest>)::$_0, mozilla::net::DocumentLoadListener::TriggerRedirectToRealChannel(mozilla::Maybe<mozilla::dom::ContentParent*> const&, nsTArray<mozilla::net::StreamFilterRequest>)::$_1>::DoResolveOrRejectInternal(mozilla::MozPromise<nsresult, mozilla::ipc::ResponseRejectReason, true>::ResolveOrRejectValue&) /builds/worker/workspace/obj-build/dist/include/mozilla/MozPromise.h:856:9 (libxul.so+0x43d55aa)
INFO - PID 984 |     #24 mozilla::net::DocumentLoadListener::RedirectToRealChannelFinished(nsresult) /builds/worker/checkouts/gecko/netwerk/ipc/DocumentLoadListener.cpp:1343:22 (libxul.so+0x43aa208) (BuildId: 9410836837796488cc9bde3201fbd997d21da338)
INFO - PID 984 |     #25 non-virtual thunk to mozilla::net::HttpChannelParent::ContinueVerification(nsIAsyncVerifyRedirectReadyCallback*) /builds/worker/checkouts/gecko/netwerk/protocol/http/HttpChannelParent.cpp (libxul.so+0x41a7ae2) (BuildId: 9410836837796488cc9bde3201fbd997d21da338)
INFO - PID 984 |     #26 mozilla::net::HttpChannelParent::ContinueVerification(nsIAsyncVerifyRedirectReadyCallback*) /builds/worker/checkouts/gecko/netwerk/protocol/http/HttpChannelParent.cpp:981:16 (libxul.so+0x41a7685) (BuildId: 9410836837796488cc9bde3201fbd997d21da338)
INFO - PID 984 |     #27 ReadyToVerify /builds/worker/checkouts/gecko/netwerk/ipc/DocumentLoadListener.cpp:1348:3 (libxul.so+0x43aa730) (BuildId: 9410836837796488cc9bde3201fbd997d21da338)
INFO - PID 984 |     #28 non-virtual thunk to mozilla::net::DocumentLoadListener::ReadyToVerify(nsresult) /builds/worker/checkouts/gecko/netwerk/ipc/DocumentLoadListener.cpp (libxul.so+0x43aa730)
INFO - PID 984 |     #29 mozilla::net::DocumentLoadListener::FinishReplacementChannelSetup(nsresult) /builds/worker/checkouts/gecko/netwerk/ipc/DocumentLoadListener.cpp:1396:8 (libxul.so+0x43aa478) (BuildId: 9410836837796488cc9bde3201fbd997d21da338)
INFO - PID 984 |     #30 mozilla::net::DocumentLoadListener::ResumeSuspendedChannel(nsIStreamListener*) /builds/worker/checkouts/gecko/netwerk/ipc/DocumentLoadListener.cpp:1482:3 (libxul.so+0x43ab0ac) (BuildId: 9410836837796488cc9bde3201fbd997d21da33
INFO - PID 984 |     #31 operator() /builds/worker/checkouts/gecko/netwerk/ipc/NeckoCommon.cpp:23:25 (libxul.so+0x43ab3af) (BuildId: 9410836837796488cc9bde3201fbd997d21da338)
INFO - PID 984 |     #32 matchN<mozilla::Variant<mozilla::net::OnStartRequestParams, mozilla::net::OnDataAvailableParams, mozilla::net::OnStopRequestParams, mozilla::net::OnAfterLastPartParams> &, (lambda at /builds/worker/checkouts/gecko/netwerk/ipc/NeckoCommon.cpp:22:9), (lambda at /builds/worker/checkouts/gecko/netwerk/ipc/NeckoCommon.cpp:28:9), (lambda at /builds/worker/checkouts/gecko/netwerk/ipc/NeckoCommon.cpp:45:9), (lambda at /builds/worker/checkouts/gecko/netwerk/ipc/NeckoCommon.cpp:53:9)> /builds/worker/workspace/obj-build/dist/include/mozilla/Variant.h:309:16 (libxul.so+0x43ab3af)
INFO - PID 984 |     #33 matchN<mozilla::Variant<mozilla::net::OnStartRequestParams, mozilla::net::OnDataAvailableParams, mozilla::net::OnStopRequestParams, mozilla::net::OnAfterLastPartParams> &, (lambda at /builds/worker/checkouts/gecko/netwerk/ipc/NeckoCommon.cpp:22:9), (lambda at /builds/worker/checkouts/gecko/netwerk/ipc/NeckoCommon.cpp:28:9), (lambda at /builds/worker/checkouts/gecko/netwerk/ipc/NeckoCommon.cpp:45:9), (lambda at /builds/worker/checkouts/gecko/netwerk/ipc/NeckoCommon.cpp:53:9)> /builds/worker/workspace/obj-build/dist/include/mozilla/Variant.h:902:12 (libxul.so+0x43ab3af)
INFO - PID 984 |     #34 match<(lambda at /builds/worker/checkouts/gecko/netwerk/ipc/NeckoCommon.cpp:22:9), (lambda at /builds/worker/checkouts/gecko/netwerk/ipc/NeckoCommon.cpp:28:9), (lambda at /builds/worker/checkouts/gecko/netwerk/ipc/NeckoCommon.cpp:45:9), (lambda at /builds/worker/checkouts/gecko/netwerk/ipc/NeckoCommon.cpp:53:9)> /builds/worker/workspace/obj-build/dist/include/mozilla/Variant.h:857:12 (libxul.so+0x43ab3af)
INFO - PID 984 |     #35 mozilla::net::ForwardStreamListenerFunctions(nsTArray<mozilla::Variant<mozilla::net::OnStartRequestParams, mozilla::net::OnDataAvailableParams, mozilla::net::OnStopRequestParams, mozilla::net::OnAfterLastPartParams>>, nsIStreamListener*) /builds/worker/checkouts/gecko/netwerk/ipc/NeckoCommon.cpp:21:13 (libxul.so+0x43ab3af)
INFO - PID 984 |     #36 non-virtual thunk to mozilla::net::HttpChannelParent::OnStartRequest(nsIRequest*) /builds/worker/checkouts/gecko/netwerk/protocol/http/HttpChannelParent.cpp (libxul.so+0x41a9dc2) (BuildId: 9410836837796488cc9bde3201fbd997d21da338)
INFO - PID 984 |     #37 mozilla::net::HttpChannelParent::OnStartRequest(nsIRequest*) /builds/worker/checkouts/gecko/netwerk/protocol/http/HttpChannelParent.cpp:1183:43 (libxul.so+0x41a847b) (BuildId: 9410836837796488cc9bde3201fbd997d21da338)
INFO - PID 984 |     #38 mozilla::dom::ContentParent::AboutToLoadHttpDocumentForChild(nsIChannel*, bool*) /builds/worker/checkouts/gecko/dom/ipc/ContentParent.cpp:6410:3 (libxul.so+0x84672d4) (BuildId: 9410836837796488cc9bde3201fbd997d21da338)
INFO - PID 984 |     #39 mozilla::dom::ContentParent::TransmitBlobURLsForPrincipal(nsIPrincipal*) /builds/worker/checkouts/gecko/dom/ipc/ContentParent.cpp:6530:17 (libxul.so+0x8467936) (BuildId: 9410836837796488cc9bde3201fbd997d21da338)
INFO - PID 984 |     #40 mozilla::dom::PContentParent::SendInitBlobURLs(mozilla::Span<mozilla::dom::BlobURLRegistrationData const, 18446744073709551615ul>) /builds/worker/workspace/obj-build/ipc/ipdl/PContentParent.cpp:3302:21 (libxul.so+0x85c4218) (BuildId: 9410836837796488cc9bde3201fbd997d21da338)
INFO - PID 984 |     #41 mozilla::ipc::IProtocol::ChannelSend(mozilla::UniquePtr<IPC::Message, mozilla::DefaultDelete<IPC::Message>>) /builds/worker/checkouts/gecko/ipc/glue/ProtocolUtils.cpp:517:22 (libxul.so+0x4696f10) (BuildId: 9410836837796488cc9bde3201fbd997d21da338)
INFO - PID 984 |     #42 mozilla::ipc::MessageChannel::Send(mozilla::UniquePtr<IPC::Message, mozilla::DefaultDelete<IPC::Message>>) /builds/worker/checkouts/gecko/ipc/glue/MessageChannel.cpp:780:3 (libxul.so+0x467bcbe) (BuildId: 9410836837796488cc9bde3201fbd997d21da338)
INFO - PID 984 |     #43 mozilla::ipc::MessageChannel::SendMessageToLink(mozilla::UniquePtr<IPC::Message, mozilla::DefaultDelete<IPC::Message>>) /builds/worker/checkouts/gecko/ipc/glue/MessageChannel.cpp:811:10 (libxul.so+0x467c6a6) (BuildId: 9410836837796488cc9bde3201fbd997d21da338)
INFO - PID 984 |     #44 mozilla::ipc::PortLink::SendMessage(mozilla::UniquePtr<IPC::Message, mozilla::DefaultDelete<IPC::Message>>) /builds/worker/checkouts/gecko/ipc/glue/MessageLink.cpp:130:16 (libxul.so+0x4687432) (BuildId: 9410836837796488cc9bde3201fbd997d21da338)
INFO - PID 984 |     #45 mozilla::ipc::NodeController::SendUserMessage(mojo::core::ports::PortRef const&, mozilla::UniquePtr<IPC::Message, mozilla::DefaultDelete<IPC::Message>>) /builds/worker/checkouts/gecko/ipc/glue/NodeController.cpp:150:19 (libxul.so+0x4687700) (BuildId: 9410836837796488cc9bde3201fbd997d21da338)
INFO - PID 984 |     #46 mojo::core::ports::Node::SendUserMessage(mojo::core::ports::PortRef const&, mozilla::UniquePtr<mojo::core::ports::UserMessageEvent, mozilla::DefaultDelete<mojo::core::ports::UserMessageEvent>>) /builds/worker/checkouts/gecko/ipc/chromium/src/mojo/core/ports/node.cc:380:12 (libxul.so+0x45cda5e) (BuildId: 9410836837796488cc9bde3201fbd997d21da338)
INFO - PID 984 |     #47 mojo::core::ports::Node::SendUserMessageInternal(mojo::core::ports::PortRef const&, mozilla::UniquePtr<mojo::core::ports::UserMessageEvent, mozilla::DefaultDelete<mojo::core::ports::UserMessageEvent>>*) /builds/worker/checkouts/gecko/ipc/chromium/src/mojo/core/ports/node.cc:1254:12 (libxul.so+0x45cdd3e) (BuildId: 9410836837796488cc9bde3201fbd997d21da338)
INFO - PID 984 |     #48 Lock /builds/worker/workspace/obj-build/dist/include/mozilla/Mutex.h:66:48 (libxul.so+0x45d65cd) (BuildId: 9410836837796488cc9bde3201fbd997d21da338)
INFO - PID 984 |     #49 BaseAutoLock /builds/worker/workspace/obj-build/dist/include/mozilla/Mutex.h:237:11 (libxul.so+0x45d65cd)
INFO - PID 984 |     #50 mojo::core::ports::Node::PrepareToForwardUserMessage(mojo::core::ports::PortRef const&, mojo::core::ports::Port::State, bool, mojo::core::ports::UserMessageEvent*, mojo::core::ports::NodeName*) /builds/worker/checkouts/gecko/ipc/chromium/src/mojo/core/ports/node.cc:1546:28 (libxul.so+0x45d65cd)
INFO - PID 984 |     #51 mutexLock /builds/worker/checkouts/gecko/mozglue/misc/Mutex_posix.cpp:94:3 (firefox-bin+0x1bb938) (BuildId: 86f8757bf323fdb2d18d9f480e442f873a859b7a)
INFO - PID 984 |     #52 mozilla::detail::MutexImpl::lock() /builds/worker/checkouts/gecko/mozglue/misc/Mutex_posix.cpp:116:43 (firefox-bin+0x1bb938)
INFO - PID 984 |     #53 pthread_mutex_lock /builds/worker/fetches/llvm-project/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp:1339:3 (firefox-bin+0xc771b) (BuildId: 86f8757bf323fdb2d18d9f480e442f873a859b7a)

Mike and Christian, shall we consider to apply this patch by default to make it easier to get these details? Otherwise I wonder if it would make sense to talk to the thread-sanitizer folks as well if that could be enabled by default. Having only the message is pretty useless.

Flags: needinfo?(mh+mozilla)
Flags: needinfo?(choller)
Component: Sanitizers → IPC
Flags: needinfo?(smayya)

We also have the same kind of timeout for html5 parser tests. The stack is slightly different but has similar frames beyound the NodeController:
https://treeherder.mozilla.org/logviewer?job_id=453317426&repo=try&lineNumber=65213

INFO - PID 26339 |     #0 __libc_start_main /tmp/glibc/csu/../csu/libc-start.c:310 (libc.so.6+0x21b96) (BuildId: 3247775c25514939b9a5ffa9d3be63f3a4cb9641)
INFO - PID 26339 |     #1 do_main /builds/worker/checkouts/gecko/browser/app/nsBrowserApp.cpp:227:22 (firefox-bin+0x14ea60) (BuildId: bd18cbe42f9147b5be83537fc6c69eec7933360d)
INFO - PID 26339 |     #2 main /builds/worker/checkouts/gecko/browser/app/nsBrowserApp.cpp:445:16 (firefox-bin+0x14ea60)
INFO - PID 26339 |     #3 mozilla::BootstrapImpl::XRE_main(int, char**, mozilla::BootstrapConfig const&) /builds/worker/checkouts/gecko/toolkit/xre/Bootstrap.cpp:45:12 (libxul.so+0xb2b30a2) (BuildId: 62705f9254b516acf0864d12749aa03688e56109)
INFO - PID 26339 |     #4 XRE_main(int, char**, mozilla::BootstrapConfig const&) /builds/worker/checkouts/gecko/toolkit/xre/nsAppRunner.cpp:6015:21 (libxul.so+0xb2a3941) (BuildId: 62705f9254b516acf0864d12749aa03688e56109)
INFO - PID 26339 |     #5 XREMain::XRE_main(int, char**, mozilla::BootstrapConfig const&) /builds/worker/checkouts/gecko/toolkit/xre/nsAppRunner.cpp:5958:8 (libxul.so+0xb2a3290) (BuildId: 62705f9254b516acf0864d12749aa03688e56109)
INFO - PID 26339 |     #6 XREMain::XRE_mainRun() /builds/worker/checkouts/gecko/toolkit/xre/nsAppRunner.cpp:5746:22 (libxul.so+0xb2a2630) (BuildId: 62705f9254b516acf0864d12749aa03688e56109)
INFO - PID 26339 |     #7 nsAppStartup::Run() /builds/worker/checkouts/gecko/toolkit/components/startup/nsAppStartup.cpp:296:30 (libxul.so+0xb1175d2) (BuildId: 62705f9254b516acf0864d12749aa03688e56109)
INFO - PID 26339 |     #8 nsAppShell::Run() /builds/worker/checkouts/gecko/widget/gtk/nsAppShell.cpp:470:33 (libxul.so+0x8dd85ac) (BuildId: 62705f9254b516acf0864d12749aa03688e56109)
INFO - PID 26339 |     #9 nsBaseAppShell::Run() /builds/worker/checkouts/gecko/widget/nsBaseAppShell.cpp:148:27 (libxul.so+0x8cd7c43) (BuildId: 62705f9254b516acf0864d12749aa03688e56109)
INFO - PID 26339 |     #10 RunInternal /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:370:10 (libxul.so+0x45991a8) (BuildId: 62705f9254b516acf0864d12749aa03688e56109)
INFO - PID 26339 |     #11 RunHandler /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:363:3 (libxul.so+0x45991a8)
INFO - PID 26339 |     #12 MessageLoop::Run() /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:345:3 (libxul.so+0x45991a8)
INFO - PID 26339 |     #13 mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) /builds/worker/checkouts/gecko/ipc/glue/MessagePump.cpp:85:21 (libxul.so+0x46888de) (BuildId: 62705f9254b516acf0864d12749aa03688e56109)
INFO - PID 26339 |     #14 NS_ProcessNextEvent(nsIThread*, bool) /builds/worker/checkouts/gecko/xpcom/threads/nsThreadUtils.cpp:480:10 (libxul.so+0x395b774) (BuildId: 62705f9254b516acf0864d12749aa03688e56109)
INFO - PID 26339 |     #15 nsThread::ProcessNextEvent(bool, bool*) /builds/worker/checkouts/gecko/xpcom/threads/nsThread.cpp:1222:3 (libxul.so+0x3954fbf) (BuildId: 62705f9254b516acf0864d12749aa03688e56109)
INFO - PID 26339 |     #16 nsThread::DrainDirectTasks() /builds/worker/checkouts/gecko/xpcom/threads/nsThread.cpp:1397:16 (libxul.so+0x3955e6e) (BuildId: 62705f9254b516acf0864d12749aa03688e56109)
INFO - PID 26339 |     #17 mozilla::SimpleTaskQueue::DrainTasks() /builds/worker/workspace/obj-build/dist/include/mozilla/TaskDispatcher.h:44:10 (libxul.so+0x3932e01) (BuildId: 62705f9254b516acf0864d12749aa03688e56109)
INFO - PID 26339 |     #18 mozilla::MozPromise<nsresult, mozilla::ipc::ResponseRejectReason, true>::ThenValueBase::ResolveOrRejectRunnable::Run() /builds/worker/workspace/obj-build/dist/include/mozilla/MozPromise.h:487:21 (libxul.so+0x43c9935) (BuildId: 62705f9254b516acf0864d12749aa03688e56109)
INFO - PID 26339 |     #19 mozilla::MozPromise<nsresult, mozilla::ipc::ResponseRejectReason, true>::ThenValueBase::DoResolveOrReject(mozilla::MozPromise<nsresult, mozilla::ipc::ResponseRejectReason, true>::ResolveOrRejectValue&) /builds/worker/workspace/obj-build/dist/include/mozilla/MozPromise.h:620:7 (libxul.so+0x43ca131) (BuildId: 62705f9254b516acf0864d12749aa03688e56109)
INFO - PID 26339 |     #20 operator() /builds/worker/checkouts/gecko/netwerk/ipc/DocumentLoadListener.cpp:2303:19 (libxul.so+0x43d55aa) (BuildId: 62705f9254b516acf0864d12749aa03688e56109)
INFO - PID 26339 |     #21 InvokeMethod<(lambda at /builds/worker/checkouts/gecko/netwerk/ipc/DocumentLoadListener.cpp:2294:11), void ((lambda at /builds/worker/checkouts/gecko/netwerk/ipc/DocumentLoadListener.cpp:2294:11)::*)(const nsresult &), nsresult> /builds/worker/workspace/obj-build/dist/include/mozilla/MozPromise.h:651:12 (libxul.so+0x43d55aa)
INFO - PID 26339 |     #22 InvokeCallbackMethod<false, (lambda at /builds/worker/checkouts/gecko/netwerk/ipc/DocumentLoadListener.cpp:2294:11), void ((lambda at /builds/worker/checkouts/gecko/netwerk/ipc/DocumentLoadListener.cpp:2294:11)::*)(const nsresult &), nsresult, RefPtr<mozilla::MozPromise<nsresult, mozilla::ipc::ResponseRejectReason, true>::Private> > /builds/worker/workspace/obj-build/dist/include/mozilla/MozPromise.h:682:5 (libxul.so+0x43d55aa)
INFO - PID 26339 |     #23 mozilla::MozPromise<nsresult, mozilla::ipc::ResponseRejectReason, true>::ThenValue<mozilla::net::DocumentLoadListener::TriggerRedirectToRealChannel(mozilla::Maybe<mozilla::dom::ContentParent*> const&, nsTArray<mozilla::net::StreamFilterRequest>)::$_0, mozilla::net::DocumentLoadListener::TriggerRedirectToRealChannel(mozilla::Maybe<mozilla::dom::ContentParent*> const&, nsTArray<mozilla::net::StreamFilterRequest>)::$_1>::DoResolveOrRejectInternal(mozilla::MozPromise<nsresult, mozilla::ipc::ResponseRejectReason, true>::ResolveOrRejectValue&) /builds/worker/workspace/obj-build/dist/include/mozilla/MozPromise.h:856:9 (libxul.so+0x43d55aa)
INFO - PID 26339 |     #24 mozilla::net::DocumentLoadListener::RedirectToRealChannelFinished(nsresult) /builds/worker/checkouts/gecko/netwerk/ipc/DocumentLoadListener.cpp:1343:22 (libxul.so+0x43aa208) (BuildId: 62705f9254b516acf0864d12749aa03688e56109)
INFO - PID 26339 |     #25 non-virtual thunk to mozilla::net::HttpChannelParent::ContinueVerification(nsIAsyncVerifyRedirectReadyCallback*) /builds/worker/checkouts/gecko/netwerk/protocol/http/HttpChannelParent.cpp (libxul.so+0x41a7ae2) (BuildId: 62705f9254b516acf0864d12749aa03688e56109)
INFO - PID 26339 |     #26 mozilla::net::HttpChannelParent::ContinueVerification(nsIAsyncVerifyRedirectReadyCallback*) /builds/worker/checkouts/gecko/netwerk/protocol/http/HttpChannelParent.cpp:981:16 (libxul.so+0x41a7685) (BuildId: 62705f9254b516acf0864d12749aa03688e56109)
INFO - PID 26339 |     #27 ReadyToVerify /builds/worker/checkouts/gecko/netwerk/ipc/DocumentLoadListener.cpp:1348:3 (libxul.so+0x43aa730) (BuildId: 62705f9254b516acf0864d12749aa03688e56109)
INFO - PID 26339 |     #28 non-virtual thunk to mozilla::net::DocumentLoadListener::ReadyToVerify(nsresult) /builds/worker/checkouts/gecko/netwerk/ipc/DocumentLoadListener.cpp (libxul.so+0x43aa730)
INFO - PID 26339 |     #29 mozilla::net::DocumentLoadListener::FinishReplacementChannelSetup(nsresult) /builds/worker/checkouts/gecko/netwerk/ipc/DocumentLoadListener.cpp:1396:8 (libxul.so+0x43aa478) (BuildId: 62705f9254b516acf0864d12749aa03688e56109)
INFO - PID 26339 |     #30 mozilla::net::DocumentLoadListener::ResumeSuspendedChannel(nsIStreamListener*) /builds/worker/checkouts/gecko/netwerk/ipc/DocumentLoadListener.cpp:1482:3 (libxul.so+0x43ab0ac) (BuildId: 62705f9254b516acf0864d12749aa03688e56109)
INFO - PID 26339 |     #31 operator() /builds/worker/checkouts/gecko/netwerk/ipc/NeckoCommon.cpp:23:25 (libxul.so+0x43ab3af) (BuildId: 62705f9254b516acf0864d12749aa03688e56109)
INFO - PID 26339 |     #32 matchN<mozilla::Variant<mozilla::net::OnStartRequestParams, mozilla::net::OnDataAvailableParams, mozilla::net::OnStopRequestParams, mozilla::net::OnAfterLastPartParams> &, (lambda at /builds/worker/checkouts/gecko/netwerk/ipc/NeckoCommon.cpp:22:9), (lambda at /builds/worker/checkouts/gecko/netwerk/ipc/NeckoCommon.cpp:28:9), (lambda at /builds/worker/checkouts/gecko/netwerk/ipc/NeckoCommon.cpp:45:9), (lambda at /builds/worker/checkouts/gecko/netwerk/ipc/NeckoCommon.cpp:53:9)> /builds/worker/workspace/obj-build/dist/include/mozilla/Variant.h:309:16 (libxul.so+0x43ab3af)
INFO - PID 26339 |     #33 matchN<mozilla::Variant<mozilla::net::OnStartRequestParams, mozilla::net::OnDataAvailableParams, mozilla::net::OnStopRequestParams, mozilla::net::OnAfterLastPartParams> &, (lambda at /builds/worker/checkouts/gecko/netwerk/ipc/NeckoCommon.cpp:22:9), (lambda at /builds/worker/checkouts/gecko/netwerk/ipc/NeckoCommon.cpp:28:9), (lambda at /builds/worker/checkouts/gecko/netwerk/ipc/NeckoCommon.cpp:45:9), (lambda at /builds/worker/checkouts/gecko/netwerk/ipc/NeckoCommon.cpp:53:9)> /builds/worker/workspace/obj-build/dist/include/mozilla/Variant.h:902:12 (libxul.so+0x43ab3af)
INFO - PID 26339 |     #34 match<(lambda at /builds/worker/checkouts/gecko/netwerk/ipc/NeckoCommon.cpp:22:9), (lambda at /builds/worker/checkouts/gecko/netwerk/ipc/NeckoCommon.cpp:28:9), (lambda at /builds/worker/checkouts/gecko/netwerk/ipc/NeckoCommon.cpp:45:9), (lambda at /builds/worker/checkouts/gecko/netwerk/ipc/NeckoCommon.cpp:53:9)> /builds/worker/workspace/obj-build/dist/include/mozilla/Variant.h:857:12 (libxul.so+0x43ab3af)
INFO - PID 26339 |     #35 mozilla::net::ForwardStreamListenerFunctions(nsTArray<mozilla::Variant<mozilla::net::OnStartRequestParams, mozilla::net::OnDataAvailableParams, mozilla::net::OnStopRequestParams, mozilla::net::OnAfterLastPartParams>>, nsIStreamListener*) /builds/worker/checkouts/gecko/netwerk/ipc/NeckoCommon.cpp:21:13 (libxul.so+0x43ab3af)
INFO - PID 26339 |     #36 non-virtual thunk to mozilla::net::HttpChannelParent::OnStartRequest(nsIRequest*) /builds/worker/checkouts/gecko/netwerk/protocol/http/HttpChannelParent.cpp (libxul.so+0x41a9dc2) (BuildId: 62705f9254b516acf0864d12749aa03688e56109)
INFO - PID 26339 |     #37 mozilla::net::HttpChannelParent::OnStartRequest(nsIRequest*) /builds/worker/checkouts/gecko/netwerk/protocol/http/HttpChannelParent.cpp:1183:43 (libxul.so+0x41a847b) (BuildId: 62705f9254b516acf0864d12749aa03688e56109)
INFO - PID 26339 |     #38 mozilla::dom::ContentParent::AboutToLoadHttpDocumentForChild(nsIChannel*, bool*) /builds/worker/checkouts/gecko/dom/ipc/ContentParent.cpp:6410:3 (libxul.so+0x84672d4) (BuildId: 62705f9254b516acf0864d12749aa03688e56109)
INFO - PID 26339 |     #39 mozilla::dom::ContentParent::TransmitBlobURLsForPrincipal(nsIPrincipal*) /builds/worker/checkouts/gecko/dom/ipc/ContentParent.cpp:6530:17 (libxul.so+0x8467936) (BuildId: 62705f9254b516acf0864d12749aa03688e56109)
INFO - PID 26339 |     #40 mozilla::dom::PContentParent::SendInitBlobURLs(mozilla::Span<mozilla::dom::BlobURLRegistrationData const, 18446744073709551615ul>) /builds/worker/workspace/obj-build/ipc/ipdl/PContentParent.cpp:3302:21 (libxul.so+0x85c4218) (BuildId: 62705f9254b516acf0864d12749aa03688e56109)
INFO - PID 26339 |     #41 mozilla::ipc::IProtocol::ChannelSend(mozilla::UniquePtr<IPC::Message, mozilla::DefaultDelete<IPC::Message>>) /builds/worker/checkouts/gecko/ipc/glue/ProtocolUtils.cpp:517:22 (libxul.so+0x4696f10) (BuildId: 62705f9254b516acf0864d12749aa03688e56109)
INFO - PID 26339 |     #42 mozilla::ipc::MessageChannel::Send(mozilla::UniquePtr<IPC::Message, mozilla::DefaultDelete<IPC::Message>>) /builds/worker/checkouts/gecko/ipc/glue/MessageChannel.cpp:780:3 (libxul.so+0x467bcbe) (BuildId: 62705f9254b516acf0864d12749aa03688e56109)
INFO - PID 26339 |     #43 mozilla::ipc::MessageChannel::SendMessageToLink(mozilla::UniquePtr<IPC::Message, mozilla::DefaultDelete<IPC::Message>>) /builds/worker/checkouts/gecko/ipc/glue/MessageChannel.cpp:811:10 (libxul.so+0x467c6a6) (BuildId: 62705f9254b516acf0864d12749aa03688e56109)
INFO - PID 26339 |     #44 mozilla::ipc::PortLink::SendMessage(mozilla::UniquePtr<IPC::Message, mozilla::DefaultDelete<IPC::Message>>) /builds/worker/checkouts/gecko/ipc/glue/MessageLink.cpp:130:16 (libxul.so+0x4687432) (BuildId: 62705f9254b516acf0864d12749aa03688e56109)
INFO - PID 26339 |     #45 mozilla::ipc::NodeController::SendUserMessage(mojo::core::ports::PortRef const&, mozilla::UniquePtr<IPC::Message, mozilla::DefaultDelete<IPC::Message>>) /builds/worker/checkouts/gecko/ipc/glue/NodeController.cpp:150:19 (libxul.so+0x4687700) (BuildId: 62705f9254b516acf0864d12749aa03688e56109)
INFO - PID 26339 |     #46 mojo::core::ports::Node::SendUserMessage(mojo::core::ports::PortRef const&, mozilla::UniquePtr<mojo::core::ports::UserMessageEvent, mozilla::DefaultDelete<mojo::core::ports::UserMessageEvent>>) /builds/worker/checkouts/gecko/ipc/chromium/src/mojo/core/ports/node.cc:380:12 (libxul.so+0x45cda5e) (BuildId: 62705f9254b516acf0864d12749aa03688e56109)
INFO - PID 26339 |     #47 mojo::core::ports::Node::SendUserMessageInternal(mojo::core::ports::PortRef const&, mozilla::UniquePtr<mojo::core::ports::UserMessageEvent, mozilla::DefaultDelete<mojo::core::ports::UserMessageEvent>>*) /builds/worker/checkouts/gecko/ipc/chromium/src/mojo/core/ports/node.cc:1254:12 (libxul.so+0x45cdd3e) (BuildId: 62705f9254b516acf0864d12749aa03688e56109)
INFO - PID 26339 |     #48 mojo::core::ports::Node::PrepareToForwardUserMessage(mojo::core::ports::PortRef const&, mojo::core::ports::Port::State, bool, mojo::core::ports::UserMessageEvent*, mojo::core::ports::NodeName*) /builds/worker/checkouts/gecko/ipc/chromium/src/mojo/core/ports/node.cc:1562:16 (libxul.so+0x45d6ae2) (BuildId: 62705f9254b516acf0864d12749aa03688e56109)
INFO - PID 26339 |     #49 Lock /builds/worker/checkouts/gecko/ipc/chromium/src/mojo/core/ports/port.h:44:35 (libxul.so+0x45d870b) (BuildId: 62705f9254b516acf0864d12749aa03688e56109)
INFO - PID 26339 |     #50 mojo::core::ports::PortLocker::PortLocker(mojo::core::ports::PortRef const**, unsigned long) /builds/worker/checkouts/gecko/ipc/chromium/src/mojo/core/ports/port_locker.cc:46:34 (libxul.so+0x45d870b)
INFO - PID 26339 |     #51 mutexLock /builds/worker/checkouts/gecko/mozglue/misc/Mutex_posix.cpp:94:3 (firefox-bin+0x1bb938) (BuildId: bd18cbe42f9147b5be83537fc6c69eec7933360d)
INFO - PID 26339 |     #52 mozilla::detail::MutexImpl::lock() /builds/worker/checkouts/gecko/mozglue/misc/Mutex_posix.cpp:116:43 (firefox-bin+0x1bb938)
INFO - PID 26339 |     #53 pthread_mutex_lock /builds/worker/fetches/llvm-project/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp:1339:3 (firefox-bin+0xc771b) (BuildId: bd18cbe42f9147b5be83537fc6c69eec7933360d)

Jed, could you please help us to figure out what's wrong here?

Flags: needinfo?(jld)

I'm not convinced the patch is all that useful. Why? Because it's not about recursive mutexes as implied by the google groups message. It's about all locks held at the same time on the same thread. You'd need to list them all for it to be somewhat useful.

Here's a simple way to reproduce the issues:

#include <pthread.h>

#define N 80
int main() {
	pthread_mutex_t mutexes[N];
	int i;
	for (i = 0; i < N; i++) {
		pthread_mutex_init(&mutexes[i], NULL);
		pthread_mutex_lock(&mutexes[i]);
	}
	return 0;
}

Compile with clang -fsanitize=thread

So yeah, what this means is that the thread is somehow holding at least 64 different locks, and tsan doesn't support tracking more than that. We /could/ increase the value, but having that many locks held at the same time sounds like a problem waiting to happen.

Flags: needinfo?(mh+mozilla)

(In reply to Henrik Skupin [:whimboo][⌚️UTC+1] from comment #13)

We also have the same kind of timeout for html5 parser tests. The stack is slightly different but has similar frames beyound the NodeController:
https://treeherder.mozilla.org/logviewer?job_id=453317426&repo=try&lineNumber=65213
[…]
Jed, could you please help us to figure out what's wrong here?

This seems to be the same issue as comment #14:

[task 2024-04-03T12:42:07.266Z] 12:42:07     INFO - PID 26339 | Current thread holds too many mutexes

Looking at the stacks, we're in this area of Mojo's node.cc, and we're trying to send a message with more than 63 attached ports (top-level protocol endpoints, basically). I notice that we already had to opt out of another lock checker for these objects (bug 1761547).

Nika, do you have an opinion about this? Is it reasonable to have ≥64 ports attached to one message? Should we see if there's a way to have TSan ignore these locks?

Flags: needinfo?(jld) → needinfo?(nika)

I'm a bit surprised we've never done this before and caught this issue before.

It looks like during this test we create a very large number of blob URLs for a site, and then end up causing a new process to load content from that site due to a navigation while these blob URLs are still active. Because the blob URLs are registered for the given principal, we end up sending all of them over IPC to the content process in a single SendInitBlobURLs message. As each blob comes with a corresponding IPCBlob, which in turn contains a RemoteLazyStream (https://searchfox.org/mozilla-central/rev/46dae934738073c4f51c2b628503fe3bf84f89d2/dom/file/ipc/IPCBlob.ipdlh#17), each blob is sent with a mojo port as an attachment.

In the mojo ports code, ports attached to messages are sent atomically, meaning that the locks for the port doing the sending and every single attached port are locked simultaneously (see the code linked by :jld in comment 15). It appears that this then ends up breaking tsan, as we acquire far more than the maximum 64 mutexes at once (though this is safe in reality).

Sending a massive number of ports in a single message like this is one of those things which is weird, but should be generally OK outside of these deadlock detection systems which place a limit on the number of concurrently held locks.

Theoretically, it would be possible for us to have an alternative tsan-mode for the ports code which uses a single global mutex for all ports instead of individual mutexes per-port to avoid this I suppose, though it's a bit awkward. We could also potentially change the SendInitBlobURLs code to not send them all in a single message, though I suppose that could potentially have other side-effects, and wouldn't fix the issue if it came up again elsewhere in the future (e.g. when sending a postMessage with 2000 blob attachments or something).

Flags: needinfo?(nika)

This changes the locking behaviour for IPC port mutexes in TSAN builds
to use a single shared mutex for all ports, rather than individual
mutexes per-port. This avoids the need to potentially lock a large
number of mutexes silmultaneously when sending a large number of ports
in an IPC message.

I've tried to leave in the various debug assertions such that it still
acts like there are multiple mutexes under the hood. It is likely that
this could harm performance somewhat due to the increased contention,
however it should have no impact on actual release builds.

Assignee: nobody → nika
Status: NEW → ASSIGNED
Pushed by nlayzell@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/deed555f59b4 Reduce the number of mutexes used by mojo in TSAN builds, r=ipc-reviewers,mccr8
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 126 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: