Closed Bug 824340 Opened 7 years ago Closed 7 years ago

DMD deadlocks getting a stack trace while another thread is releasing an shlib

Categories

(Core :: DMD, defect)

x86_64
Linux
defect
Not set

Tracking

()

RESOLVED FIXED
mozilla20

People

(Reporter: neil, Assigned: njn)

References

Details

Attachments

(2 files)

Attached file thread apply all bt
I created a DMD-enabled build and it deadlocked while restoring my session.

Thread 1 was doing something with fonts that was causing an shlib to be released. This locks the internal list of loaded libraries, but also calls free, which of course DMD tries to track, and needs to lock its mutex to do so.

Thread 4 was trying to allocate memory, so DMD had locked its mutex, and then tried to walk the stack, which internally needs the list of loaded libraries.
Thanks for the clear analysis, Neil.

We have some existing windows-only code to protect against this case.  Clearly
it's needed on other platforms.  This patch does that.

(trace-malloc has similar deadlock-avoidance code enabled on all platforms,
and when transferring it to DMD it got made Windows-only because the comment
only mentioned Windows!)
Attachment #695371 - Flags: review?(justin.lebar+bug)
Assignee: nobody → n.nethercote
Comment on attachment 695371 [details] [diff] [review]
DMD: fix a deadlock when getting stack traces.

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

Neil, can you test this patch?  Thanks.
Attachment #695371 - Flags: feedback?(neil)
Attachment #695371 - Flags: feedback?(neil) → feedback+
Comment on attachment 695371 [details] [diff] [review]
DMD: fix a deadlock when getting stack traces.

Can't argue with this.
Attachment #695371 - Flags: review?(justin.lebar+bug) → review+
https://hg.mozilla.org/mozilla-central/rev/eb1a9250d68a
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla20
Component: General → DMD
You need to log in before you can comment on or make changes to this bug.