Chrome hang monitor can deadlock the browser

RESOLVED FIXED in mozilla16

Status

()

Core
XPCOM
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: khuey, Unassigned)

Tracking

unspecified
mozilla16
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [ironic])

Attachments

(1 attachment)

The chrome hang monitor suspends the hung thread, walks its stack, and then resumes the thread (http://mxr.mozilla.org/mozilla-central/source/xpcom/threads/HangMonitor.cpp#122).

This falls down if the suspended thread holds the allocator lock.  When the stack walker tries to malloc at http://mxr.mozilla.org/mozilla-central/source/xpcom/threads/HangMonitor.cpp#114, we deadlock.  I hit this on my local machine today.
Created attachment 640811 [details] [diff] [review]
Don't allocate memory while a thread is suspended
Attachment #640811 - Flags: review?(ehsan)
Comment on attachment 640811 [details] [diff] [review]
Don't allocate memory while a thread is suspended

Review of attachment 640811 [details] [diff] [review]:
-----------------------------------------------------------------

::: xpcom/threads/HangMonitor.cpp
@@ +123,5 @@
>    MOZ_ASSERT(winMainThreadHandle);
> +
> +  // The thread we're about to suspend might have the alloc lock
> +  // so allocate ahead of time
> +  callStack.SetCapacity(400);

Nit: Please make this a static const with a sensible name and put it perhaps after line 23.
Attachment #640811 - Flags: review?(ehsan) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/45c7c796fd81
Attachment #640811 - Flags: checkin+
https://hg.mozilla.org/mozilla-central/rev/45c7c796fd81
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla16

Updated

5 years ago
Whiteboard: [ironic]
You need to log in before you can comment on or make changes to this bug.