Closed Bug 378716 Opened 18 years ago Closed 17 years ago

Deadlock when _win32_scaled_font_create fails and calls cairo_scaled_font_destroy

Categories

(Core :: Graphics, defect)

x86
Windows XP
defect
Not set
critical

Tracking

()

RESOLVED FIXED

People

(Reporter: longsonr, Assigned: MatsPalmgren_bugz)

References

Details

(Keywords: hang, regression, testcase)

Attachments

(3 files, 2 obsolete files)

Attached image testcase (deleted) —
No description provided.
testcase asserts in a debug build. _moz_cairo_set_scaled_font is called with scaled_font = NULL then the line cr->status = scaled_font->status; goes boom. Call stack: _moz_cairo_set_scaled_font gfxWindowsFont::SetupCairoFont gfxFont::Draw gfxWindowsFont::Draw gfxTextRun::DrawGlyphs gfxTextRun::Draw nsSVGGlyphFrame::LoopCharacters ... Prior to this gfxWindowsFont::MakeCairoScaledFont is called with mAdjustedSize = 0 so the call to cairo_scaled_font_create returns NULL
Severity: normal → critical
Keywords: crash
Summary: Browser crashes with small font-size → Browser crashes with small font-size [@ _moz_cairo_set_scaled_font]
Blocks: 293852
Blocks: 386452
No longer blocks: 386452
The patch in bug 390476 fixes this crash.
Depends on: 390476
After bug 390476 was fixed it hangs instead.
Keywords: crashhang
Attached file deadlock stack (deleted) —
The hang is a deadlock on _cairo_scaled_font_map_mutex: _moz_cairo_scaled_font_create() acquires the lock and calls font_face->backend->scaled_font_create(). We end up in _win32_scaled_font_create() which fails setup the font so it calls _moz_cairo_scaled_font_destroy() which tries to acquire the same mutex and hangs.
Assignee: general → nobody
Component: SVG → GFX: Thebes
QA Contact: ian → thebes
Summary: Browser crashes with small font-size [@ _moz_cairo_set_scaled_font] → Deadlock when _win32_scaled_font_create fails and calls cairo_scaled_font_destroy
Attached patch WIP (obsolete) (deleted) — Splinter Review
FWIW, this fixes it. Or we could make the mutex recursive, if we have support for that type of mutex.
Blocks: 389726
Uhm, I'm pretty sure we set CAIRO_NO_MUTEX... though now that I look at it, that still creates some variables to use as faux mutexes. Ugh.
Attached patch patch 2 (obsolete) (deleted) — Splinter Review
Right, it's their "poor man's mutex" that deadlocks on a recursive call from the same thread. They really should provide a true NOP alternative for applications that does all Cairo calls from the same thread. Saves us a few assignments too ;-)
Attachment #275701 - Attachment is obsolete: true
Attachment #278547 - Flags: superreview?(vladimir)
Attachment #278547 - Flags: review?(vladimir)
Comment on attachment 278547 [details] [diff] [review] patch 2 Can you add a copy of this patch into the gfx/cairo dir, and add a note into the README about what it's for?
Attachment #278547 - Flags: superreview?(vladimir)
Attachment #278547 - Flags: superreview+
Attachment #278547 - Flags: review?(vladimir)
Attachment #278547 - Flags: review+
Attachment #278547 - Flags: approval1.9+
Actually, hold on -- I don't think that function should be calling scaled_font_destroy at all.
Comment on attachment 278547 [details] [diff] [review] patch 2 Yeah, the cairo_scaled_font_destroy (&f->base); should just be a free(f);
Attachment #278547 - Flags: superreview+
Attachment #278547 - Flags: review+
Attachment #278547 - Flags: approval1.9+
Attached patch patch 3 (deleted) — Splinter Review
Good catch. I think we also need a _cairo_scaled_font_fini in case _cairo_scaled_font_init succeeded. I've included the patch in gfx/cairo/ and added an entry in README.
Attachment #278547 - Attachment is obsolete: true
Attachment #278810 - Flags: superreview?(vladimir)
Attachment #278810 - Flags: review?(vladimir)
Attachment #278810 - Flags: superreview?(vladimir)
Attachment #278810 - Flags: superreview+
Attachment #278810 - Flags: review?(vladimir)
Attachment #278810 - Flags: review+
Attachment #278810 - Flags: approval1.9+
So do we still need the really-noop mutexes mutex code?
1. it saves a few unnecessary integer read/write ops 2. more importantly, it avoids deadlocking in case there is (or someone introduces) another recursive path to the same mutex
In theory the mutexes aren't supposed to be recursive; I think a recursive acquisition is supposed to be an error condition. That's the case for the linux mutexes at least, but not for the win32 ones (EnterCriticalSection allows for recursive acquisition). Though the poor man's mutex isn't really doing anyone any favours anyway...
Assignee: nobody → mats.palmgren
mozilla/gfx/cairo/cairo/src/cairo-mutex-type-private.h 1.7 mozilla/gfx/cairo/cairo/src/cairo-win32-font.c 1.34 mozilla/gfx/cairo/README 1.62 mozilla/gfx/cairo/scaled-font-create-deadlock.patch 1.1 -> FIXED
Status: NEW → RESOLVED
Closed: 17 years ago
Flags: in-testsuite?
Resolution: --- → FIXED
Blocks: 391953
Flags: in-testsuite? → in-testsuite+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: