Closed Bug 408736 Opened 18 years ago Closed 9 years ago

Crash [@ _cairo_clip_path_destroy] with crazy border testcase

Categories

(Core :: Graphics, defect, P2)

x86
macOS
defect

Tracking

()

RESOLVED INCOMPLETE

People

(Reporter: jruderman, Unassigned)

References

Details

(Keywords: crash, sec-vector, testcase, Whiteboard: [sg:vector-critical? (apple)] rdar://6463647)

Crash Data

Attachments

(4 files, 2 obsolete files)

This testcase is complicated and sensitive to window size :( For me, it usually crashes when the window is ~1200 pixels wide. It will slowly resize on its own if you let it (Preferences > Content > JavaScript > Advanced). Security-sensitive because it looks like we're dereferencing a bogus address, and malloc complains about heap corruption ("incorrect checksum for freed object").
Flags: blocking1.9?
Attached file stack trace (obsolete) —
Vlad, if you figure this out, it would be great if you could make a better testcase in addition to a patch. This testcase can't be used as a crashtest because of the window size dependency.
This is worksforme, using: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9b3pre) Gecko/2007121305 Minefield/3.0b3pre
Over to me for investigation
Assignee: nobody → vladimir
Flags: blocking1.9? → blocking1.9+
I've reproduced this on OSX but the stack trace is different each time; it seems that it's a general heap corruption bug, and i'm having a hell of a time tracking it down. The behaviour of the testcase is different between Fx2 and 3 -- is that intentional? In 3 the magenta element flashes, whereas in Fx2 it doesn't.
Attached file more reduced testcase —
Further reduced testcase. The trigger seems to be an element with a very large border, with inconsistent border styles. My guess is that we're overflowing Quartz's little mind somewhere; will try to figure out where.
I'm making almost no headway here. I almost always crash inside Quartz, which is worrying; the problem is reproducible with border-left: none; and border-top: 2px solid blue; (no need for dotted borders to be involved). It's reproducible for border-top of 1px and 4px but takes much longer than with 2px.
Whiteboard: [sg:critical?]
Colin/Josh, can you ask someone at Apple to help here, since Vlad thinks this is a Quartz bug?
Priority: -- → P2
I actually don't know that for sure; it's a memory corruption bug, but whose fault it is I don't have any idea. However, I recently fixed bug 407099, which was mac memory corruption. And indeed, after that, I can't get a crash with my testcase any more. Can someone verify that that's true?
You only checked that patch into upstream cairo. Should I apply the patch locally to see whether it fixes this testcase?
Ok, let the original testcase run for a few minutes as well as the other one... can't get a crash. Assuming fixed by bug 407099; please reopen if that's not the case.
Status: NEW → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
Flags: in-testsuite?
Still crashes for me. This testcase is too slow for Tinderbox, so in-testsuite-.
Status: RESOLVED → REOPENED
Flags: in-testsuite? → in-testsuite-
Resolution: FIXED → ---
Welp, now I get to blame the cycle collector: (gdb) where 10 #0 0xa803a8ff in ?? () #1 0x0034bbfd in canonicalize (in=0xd88800) at ../../../mozilla/xpcom/base/nsCycleCollector.cpp:1064 #2 0x0034c092 in GCGraphBuilder::NoteXPCOMChild (this=0xbfffd608, child=0xd88800) at ../../../mozilla/xpcom/base/nsCycleCollector.cpp:1339 #3 0x12a291ec in SubDocTraverser (table=0x1ecfaeb0, hdr=0x1eedd5c0, number=0, arg=0xbfffd608) at ../../../../mozilla/content/base/src/nsDocument.cpp:901 #4 0x002b499f in PL_DHashTableEnumerate (table=0x1ecfaeb0, etor=0x12a291a2 <SubDocTraverser>, arg=0xbfffd608) at pldhash.c:724 #5 0x12a2c729 in nsDocument::cycleCollection::Traverse (this=0x1305dec0, p=0xa3f800, cb=@0xbfffd608) at ../../../../mozilla/content/base/src/nsDocument.cpp:1007 #6 0x12c514d4 in nsXULDocument::cycleCollection::Traverse (this=0x1305dec0, p=0xa3f800, cb=@0xbfffd608) at ../../../../../mozilla/content/xul/document/src/nsXULDocument.cpp:326 #7 0x0034cc94 in GCGraphBuilder::Traverse (this=0xbfffd608, aPtrInfo=0x17e188d4) at ../../../mozilla/xpcom/base/nsCycleCollector.cpp:1268 #8 0x0034cdec in nsCycleCollector::MarkRoots (this=0x545000, builder=@0xbfffd608) at ../../../mozilla/xpcom/base/nsCycleCollector.cpp:1448 #9 0x0034cef2 in nsCycleCollector::BeginCollection (this=0x545000) at ../../../mozilla/xpcom/base/nsCycleCollector.cpp:2243 (More stack frames follow...) (gdb) where #0 0xa803a8ff in ?? () #1 0x0034bbfd in canonicalize (in=0xd88800) at ../../../mozilla/xpcom/base/nsCycleCollector.cpp:1064 #2 0x0034c092 in GCGraphBuilder::NoteXPCOMChild (this=0xbfffd608, child=0xd88800) at ../../../mozilla/xpcom/base/nsCycleCollector.cpp:1339 #3 0x12a291ec in SubDocTraverser (table=0x1ecfaeb0, hdr=0x1eedd5c0, number=0, arg=0xbfffd608) at ../../../../mozilla/content/base/src/nsDocument.cpp:901 #4 0x002b499f in PL_DHashTableEnumerate (table=0x1ecfaeb0, etor=0x12a291a2 <SubDocTraverser>, arg=0xbfffd608) at pldhash.c:724 #5 0x12a2c729 in nsDocument::cycleCollection::Traverse (this=0x1305dec0, p=0xa3f800, cb=@0xbfffd608) at ../../../../mozilla/content/base/src/nsDocument.cpp:1007 #6 0x12c514d4 in nsXULDocument::cycleCollection::Traverse (this=0x1305dec0, p=0xa3f800, cb=@0xbfffd608) at ../../../../../mozilla/content/xul/document/src/nsXULDocument.cpp:326 #7 0x0034cc94 in GCGraphBuilder::Traverse (this=0xbfffd608, aPtrInfo=0x17e188d4) at ../../../mozilla/xpcom/base/nsCycleCollector.cpp:1268 #8 0x0034cdec in nsCycleCollector::MarkRoots (this=0x545000, builder=@0xbfffd608) at ../../../mozilla/xpcom/base/nsCycleCollector.cpp:1448 #9 0x0034cef2 in nsCycleCollector::BeginCollection (this=0x545000) at ../../../mozilla/xpcom/base/nsCycleCollector.cpp:2243 #10 0x0034cf53 in nsCycleCollector_beginCollection () at ../../../mozilla/xpcom/base/nsCycleCollector.cpp:2735 #11 0x11106551 in XPCCycleCollectGCCallback (cx=0x15ea5200, status=JSGC_MARK_END) at ../../../../../mozilla/js/src/xpconnect/src/nsXPConnect.cpp:437 #12 0x001c5751 in js_GC (cx=0x15ea5200, gckind=GC_NORMAL) at ../../../mozilla/js/src/jsgc.c:2526 #13 0x0017e4e5 in JS_GC (cx=0x15ea5200) at ../../../mozilla/js/src/jsapi.c:2396 #14 0x11102d47 in nsXPConnect::Collect (this=0x62bc70) at ../../../../../mozilla/js/src/xpconnect/src/nsXPConnect.cpp:526 #15 0x0034d02c in nsCycleCollector::Collect (this=0x545000, aTryCollections=1) at ../../../mozilla/xpcom/base/nsCycleCollector.cpp:2162 #16 0x0034d0cf in nsCycleCollector_collect () at ../../../mozilla/xpcom/base/nsCycleCollector.cpp:2729 #17 0x12c7ee35 in nsJSContext::CC () at ../../../../mozilla/dom/src/base/nsJSEnvironment.cpp:3306 #18 0x12c7ef52 in nsJSContext::CCIfUserInactive () at ../../../../mozilla/dom/src/base/nsJSEnvironment.cpp:3347 #19 0x12c810be in nsJSContext::Notify (this=0x18346ec0, timer=0x1ee39f10) at ../../../../mozilla/dom/src/base/nsJSEnvironment.cpp:3369 #20 0x0033c4ed in nsTimerImpl::Fire (this=0x1ee39f10) at ../../../mozilla/xpcom/threads/nsTimerImpl.cpp:403 #21 0x0033c700 in nsTimerEvent::Run (this=0x1ee50840) at ../../../mozilla/xpcom/threads/nsTimerImpl.cpp:488
Well, maybe not, now I'm crashing in CG code again, but I don't think it's CG itself. We're seeing memory corruption for sure, and the testcase really does only two things -- does lots of painting, and does cycle collection, so any crash is likely to be in one of those two places. So we're back to the same situation as before -- I have no idea how to debug this without something like valgrind. :(
Flags: wanted1.9.0.x+
Flags: tracking1.9+
Flags: blocking1.9-
Still crashes trunk in one of _cairo_clip_path_destroy or cycle collector. I tried using MallocScribble, hoping that would make the crash show up sooner, but it didn't help.
Whiteboard: [sg:critical?] → [sg:critical?] Hard to debug without Valgrind
Flags: blocking1.9.1?
Wish I could mark this blocking, but I really have no idea how to debug. It might be worth doing a bunch of printfs to write the quartz code that we're actually calling, to see if we can get a non-mozilla native quartz testcase.. that way at least we'd be able to demonstrate that it's a quartz bug.
Flags: wanted1.9.1+
Flags: blocking1.9.1?
Flags: blocking1.9.1-
Does this help? (There is now an experimental version of Valgrind available for Mac.)
Attachment #293581 - Attachment is obsolete: true
mmm. I'll have to get valgrind built so I can get a breakpoint there. There are two possiblities: 1) it's an Apple bug; 2) we're setting up an image pointer somewhere incorrectly. Actually, #1 is looking more likely -- that's a solid border, so no source image is present. We're just drawing a solid filled path. So with that breakpoint I should be able to capture the coordinates of the drawing and state, and attempt to recreate that situation as a standalone test...
Jesse, how did you get that valgrind log? fx under valgrind runs for like 30 minutes for me without printing anything or popping up a window...
Firefox debug + valgrind-opensource-3 hangs on startup; I don't know why. You can either use an opt build with symbols or revert to valgrind-opensource-2.
Well crap, this appears to have showed up on a real site, see previous dup'd bug. Argh.
Attached file standalone testcase (obsolete) —
Ok, (finally!) spent a while adding dumps and stepping through this in detail, now that I got valgrind working. The attached program reproduces the bug in valgrind. Note that in isolation this program does not cause a crash, but the valgrind error is identical. The bug only shows in the furst run of the test function though, the remainder of the program runs without error, which is odd. I also can't cause guard malloc to complain, though the error might slip through the heap checks. However, it looks like if I set the stride to be exactly what's needed instead of aligning to 16 bytes, then the problem goes away. My guess is that some code internally is allocating a buffer big enough for the actual width of one line, but is then using the stride to iterate over it.
(In reply to comment #25) > However, it looks like if I set the stride to be exactly what's needed instead > of aligning to 16 bytes, then the problem goes away. My guess is that some > code internally is allocating a buffer big enough for the actual width of one > line, but is then using the stride to iterate over it. Nope, spoke too soon.. I just hit the bug even with stride = w * 4. So there goes that idea of a workaround. It looks like it's purely the clip that causes the problem. So ignore the stride-related comments in the testcase.
Even further simplified testcase. I need to figure out how to file this with apple.
Attachment #354215 - Attachment is obsolete: true
Filed as apple bug #6463647, which I'm sure they will ignore just like the last few we've filed.
(In reply to comment #25) > Note that in isolation this program does not cause a crash, but the valgrind > error is identical. The bug only shows in the furst run of the test function > though, the remainder of the program runs without error, which is odd. I also valgrind sometimes does that, but only if the errors are at identical stacks, or something like that. Check the error count at the end of the run.
Whiteboard: [sg:critical?] Hard to debug without Valgrind → [sg:critical?] Apple bug?
Whiteboard: [sg:critical?] Apple bug? → [sg:vector-critical? (apple)] Apple bug
Whiteboard: [sg:vector-critical? (apple)] Apple bug → [sg:vector-critical? (apple)] rdar://6463647
Crash Signature: [@ _cairo_clip_path_destroy]
Keywords: sec-vector
Keywords: sec-other
Group: core-security → gfx-core-security
Status: REOPENED → RESOLVED
Closed: 18 years ago → 9 years ago
Resolution: --- → INCOMPLETE
Group: gfx-core-security
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: