WebCore::ImageBuffer::createCompatibleBuffer() in Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp over-releases CGColorSpaceRef objects in two different code paths: RetainPtr<CGColorSpaceRef> colorSpace; #if PLATFORM(COCOA) CGContextRef cgContext = context.platformContext(); switch (CGContextGetType(cgContext)) { case kCGContextTypeBitmap: colorSpace = adoptCF(CGBitmapContextGetColorSpace(cgContext)); // BUG! break; #if USE(IOSURFACE) case kCGContextTypeIOSurface: colorSpace = adoptCF(CGIOSurfaceContextGetColorSpace(cgContext)); // BUG! break; #endif default: colorSpace = adoptCF(CGContextCopyDeviceColorSpace(cgContext)); } Neither CGBitmapContextGetColorSpace() nor CGIOSurfaceContextGetColorSpace() returns a +1 retained CGColorSpaceRef, so using adoptCF() will over-release the CGColorSpaceRef object later when RetainPtr<CGColorSpaceRef> colorSpace goes out of scope. <rdar://problem/27723268>
Created attachment 290418 [details] Patch v1
<rdar://problem/27723268>
Comment on attachment 290418 [details] Patch v1 r=me
Comment on attachment 290418 [details] Patch v1 Clearing flags on attachment: 290418 Committed r206706: <http://trac.webkit.org/changeset/206706>
All reviewed patches have been landed. Closing bug.
Is this a code path that cannot be executed in layout tests?
(In reply to comment #6) > Is this a code path that cannot be executed in layout tests? No, the first case should happen in tons and tons of tests.
Why was this not detected, not even with GuardMalloc?
(In reply to comment #8) > Why was this not detected, not even with GuardMalloc? Two reasons that I'm aware of (the radar has a bit more information about CGContextGetType): 1. CGContextGetType() apparently doesn't return kCGContextTypeBitmap as often as we think it does. 2. The retain count of the CGColorSpaceRef object returned in the case of compositing/color-matching/pdf-image-match.html is somewhere in the neighborhood of 4294967295, so that one test would probably have to be run nearly 4294967295+1 times in the same process to over-release the object enough times to cause a crash.