Open Bug 1715357 Opened 3 years ago Updated 3 years ago

Large allocation after calling [@ mozilla::gfx::DrawTargetSkia::DrawGlyphs]

Categories

(Core :: Graphics: Canvas2D, defect)

defect

Tracking

()

Tracking Status
firefox91 --- affected

People

(Reporter: tsmith, Unassigned)

References

(Blocks 2 open bugs)

Details

(Keywords: csectype-oom, testcase)

Attachments

(1 file)

Attached file testcase.html

Found while fuzzing m-c 20210604-963df76dc655 (--enable-address-sanitizer --enable-fuzzing)

To help catch this issue ASAN_OPTIONS=max_allocation_size_mb=512 was used. See Bug 1715316 for details about fuzzing trigger OOMs.

==242335==WARNING: AddressSanitizer failed to allocate 0x32c8a000 bytes
=================================================================
==242335==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000001 (pc 0x55a7d3419b48 bp 0x7ffc2979d190 sp 0x7ffc2979d180 T0)
==242335==The signal is caused by a WRITE memory access.
==242335==Hint: address points to the zero page.
    #0 0x55a7d3419b48 in mozalloc_abort src/memory/mozalloc/mozalloc_abort.cpp:33:3
    #1 0x55a7d3419cdd in mozalloc_handle_oom(unsigned long) src/memory/mozalloc/mozalloc_oom.cpp:51:3
    #2 0x55a7d3419bfb in moz_xmalloc src/memory/mozalloc/mozalloc.cpp:54:5
    #3 0x7f9f24cb38b1 in operator new[] /builds/worker/workspace/obj-build/dist/include/mozilla/cxxalloc.h:42:10
    #4 0x7f9f24cb38b1 in SkArenaAlloc::ensureSpace(unsigned int, unsigned int) src/gfx/skia/skia/src/core/SkArenaAlloc.cpp:131:22
    #5 0x7f9f24b10d90 in SkArenaAlloc::allocObject(unsigned int, unsigned int) src/gfx/skia/skia/src/core/SkArenaAlloc.h:165:19
    #6 0x7f9f24f4a16a in SkArenaAlloc::makeBytesAlignedTo(unsigned long, unsigned long) src/gfx/skia/skia/src/core/SkArenaAlloc.h:131:31
    #7 0x7f9f24f4a023 in SkGlyph::allocImage(SkArenaAlloc*) src/gfx/skia/skia/src/core/SkGlyph.cpp:89:21
    #8 0x7f9f24f4a225 in SkGlyph::setImage(SkArenaAlloc*, SkScalerContext*) src/gfx/skia/skia/src/core/SkGlyph.cpp:99:15
    #9 0x7f9f2502b855 in SkStrike::prepareImage(SkGlyph*) src/gfx/skia/skia/src/core/SkStrike.cpp:126:16
    #10 0x7f9f2502c3f4 in SkStrike::prepareForDrawingMasksCPU(SkDrawableGlyphBuffer*) src/gfx/skia/skia/src/core/SkStrike.cpp:190:39
    #11 0x7f9f24f54ed5 in SkGlyphRunListPainter::drawForBitmapDevice(SkGlyphRunList const&, SkMatrix const&, SkGlyphRunListPainter::BitmapDevicePainter const*) src/gfx/skia/skia/src/core/SkGlyphRunPainter.cpp:164:21
    #12 0x7f9f24cbf4bd in SkBitmapDevice::drawGlyphRunList(SkGlyphRunList const&) src/gfx/skia/skia/src/core/SkBitmapDevice.cpp:551:5
    #13 0x7f9f24f53392 in SkGlyphRunBuilder::drawTextBlob(SkPaint const&, SkTextBlob const&, SkPoint, SkBaseDevice*) src/gfx/skia/skia/src/core/SkGlyphRun.cpp:202:17
    #14 0x7f9f24ced367 in SkCanvas::onDrawTextBlob(SkTextBlob const*, float, float, SkPaint const&) src/gfx/skia/skia/src/core/SkCanvas.cpp:2676:34
    #15 0x7f9f24cedbee in SkCanvas::drawTextBlob(SkTextBlob const*, float, float, SkPaint const&) src/gfx/skia/skia/src/core/SkCanvas.cpp:2697:11
    #16 0x7f9f1c984402 in drawTextBlob src/gfx/skia/skia/include/core/SkCanvas.h:2031:15
    #17 0x7f9f1c984402 in mozilla::gfx::DrawTargetSkia::DrawGlyphs(mozilla::gfx::ScaledFont*, mozilla::gfx::GlyphBuffer const&, mozilla::gfx::Pattern const&, mozilla::gfx::StrokeOptions const*, mozilla::gfx::DrawOptions const&) src/gfx/2d/DrawTargetSkia.cpp:1391:14
    #18 0x7f9f1d3168c5 in GlyphBufferAzure::DrawStroke(gfxContext::AzureState const&, mozilla::gfx::GlyphBuffer&) src/gfx/thebes/gfxFont.cpp:1703:7
    #19 0x7f9f1d31616d in GlyphBufferAzure::FlushGlyphs() src/gfx/thebes/gfxFont.cpp:1681:7
    #20 0x7f9f1d2e46ed in GlyphBufferAzure::~GlyphBufferAzure() src/gfx/thebes/gfxFont.cpp:1561:7
    #21 0x7f9f1d2df8cc in gfxFont::Draw(gfxTextRun const*, unsigned int, unsigned int, mozilla::gfx::PointTyped<mozilla::gfx::UnknownUnits, float>*, TextRunDrawParams const&, mozilla::gfx::ShapedTextFlags) src/gfx/thebes/gfxFont.cpp:2292:3
    #22 0x7f9f1d404111 in gfxTextRun::DrawGlyphs(gfxFont*, gfxTextRun::Range, mozilla::gfx::PointTyped<mozilla::gfx::UnknownUnits, float>*, gfxTextRun::PropertyProvider*, gfxTextRun::Range, TextRunDrawParams&, mozilla::gfx::ShapedTextFlags) const src/gfx/thebes/gfxTextRun.cpp:433:10
    #23 0x7f9f1d406318 in gfxTextRun::Draw(gfxTextRun::Range, mozilla::gfx::PointTyped<mozilla::gfx::UnknownUnits, float>, gfxTextRun::DrawParams const&) const src/gfx/thebes/gfxTextRun.cpp:680:5
    #24 0x7f9f1f849277 in mozilla::dom::CanvasBidiProcessor::DrawText(int, int) src/dom/canvas/CanvasRenderingContext2D.cpp:3712:15
    #25 0x7f9f22558f35 in nsBidiPresUtils::ProcessText(char16_t const*, int, unsigned char, nsPresContext*, nsBidiPresUtils::BidiProcessor&, nsBidiPresUtils::Mode, nsBidiPositionResolve*, int, int*, nsBidi*) src/layout/base/nsBidiPresUtils.cpp:2236:20
    #26 0x7f9f1f781e94 in mozilla::dom::CanvasRenderingContext2D::DrawOrMeasureText(nsTSubstring<char16_t> const&, float, float, mozilla::dom::Optional<double> const&, mozilla::dom::CanvasRenderingContext2D::TextDrawOperation, mozilla::ErrorResult&) src/dom/canvas/CanvasRenderingContext2D.cpp:4023:12
    #27 0x7f9f1e91cb04 in mozilla::dom::CanvasRenderingContext2D_Binding::strokeText(JSContext*, JS::Handle<JSObject*>, void*, JSJitMethodCallArgs const&) /builds/worker/workspace/obj-build/dom/bindings/CanvasRenderingContext2DBinding.cpp:6458:24
    #28 0x7f9f1f646979 in bool mozilla::dom::binding_detail::GenericMethod<mozilla::dom::binding_detail::NormalThisPolicy, mozilla::dom::binding_detail::ThrowExceptions>(JSContext*, unsigned int, JS::Value*) src/dom/bindings/BindingUtils.cpp:3298:13
    #29 0x7f9f26452182 in CallJSNative src/js/src/vm/Interpreter.cpp:426:13
    #30 0x7f9f26452182 in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct, js::CallReason) src/js/src/vm/Interpreter.cpp:511:12
    #31 0x7f9f26439b5f in CallFromStack src/js/src/vm/Interpreter.cpp:575:10
    #32 0x7f9f26439b5f in Interpret(JSContext*, js::RunState&) src/js/src/vm/Interpreter.cpp:3226:16
    #33 0x7f9f264236b6 in js::RunScript(JSContext*, js::RunState&) src/js/src/vm/Interpreter.cpp:395:13
    #34 0x7f9f264522bb in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct, js::CallReason) src/js/src/vm/Interpreter.cpp:543:13
    #35 0x7f9f26453ebb in js::Call(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, js::AnyInvokeArgs const&, JS::MutableHandle<JS::Value>, js::CallReason) src/js/src/vm/Interpreter.cpp:588:8
    #36 0x7f9f26cc12a2 in JS::Call(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, JS::HandleValueArray const&, JS::MutableHandle<JS::Value>) src/js/src/jsapi.cpp:2777:10
    #37 0x7f9f1f186af9 in mozilla::dom::EventListener::HandleEvent(mozilla::dom::BindingCallContext&, JS::Handle<JS::Value>, mozilla::dom::Event&, mozilla::ErrorResult&) /builds/worker/workspace/obj-build/dom/bindings/EventListenerBinding.cpp:58:8
    #38 0x7f9f1fdfd088 in void mozilla::dom::EventListener::HandleEvent<mozilla::dom::EventTarget*>(mozilla::dom::EventTarget* const&, mozilla::dom::Event&, mozilla::ErrorResult&, char const*, mozilla::dom::CallbackObject::ExceptionHandling, JS::Realm*) /builds/worker/workspace/obj-build/dist/include/mozilla/dom/EventListenerBinding.h:65:12
    #39 0x7f9f1fdfcb80 in mozilla::EventListenerManager::HandleEventSubType(mozilla::EventListenerManager::Listener*, mozilla::dom::Event*, mozilla::dom::EventTarget*) src/dom/events/EventListenerManager.cpp:1108:43
    #40 0x7f9f1fdfe1a7 in mozilla::EventListenerManager::HandleEventInternal(nsPresContext*, mozilla::WidgetEvent*, mozilla::dom::Event**, mozilla::dom::EventTarget*, nsEventStatus*, bool) src/dom/events/EventListenerManager.cpp:1305:17
    #41 0x7f9f1fdeb52e in mozilla::EventTargetChainItem::HandleEvent(mozilla::EventChainPostVisitor&, mozilla::ELMCreationDetector&) src/dom/events/EventDispatcher.cpp:355:17
    #42 0x7f9f1fde9d51 in mozilla::EventTargetChainItem::HandleEventTargetChain(nsTArray<mozilla::EventTargetChainItem>&, mozilla::EventChainPostVisitor&, mozilla::EventDispatchingCallback*, mozilla::ELMCreationDetector&) src/dom/events/EventDispatcher.cpp:557:16
    #43 0x7f9f1fdee155 in mozilla::EventDispatcher::Dispatch(nsISupports*, nsPresContext*, mozilla::WidgetEvent*, mozilla::dom::Event*, nsEventStatus*, mozilla::EventDispatchingCallback*, nsTArray<mozilla::dom::EventTarget*>*) src/dom/events/EventDispatcher.cpp:1116:11
    #44 0x7f9f1fdf3bd9 in mozilla::EventDispatcher::DispatchDOMEvent(nsISupports*, mozilla::WidgetEvent*, mozilla::dom::Event*, nsPresContext*, nsEventStatus*) src/dom/events/EventDispatcher.cpp
    #45 0x7f9f1dd3d39a in nsINode::DispatchEvent(mozilla::dom::Event&, mozilla::dom::CallerType, mozilla::ErrorResult&) src/dom/base/nsINode.cpp:1331:17
    #46 0x7f9f1d80f9af in nsContentUtils::DispatchEvent(mozilla::dom::Document*, nsISupports*, nsTSubstring<char16_t> const&, mozilla::CanBubble, mozilla::Cancelable, mozilla::Composed, mozilla::Trusted, bool*, mozilla::ChromeOnlyDispatch) src/dom/base/nsContentUtils.cpp:4316:28
    #47 0x7f9f1d80f6f3 in nsContentUtils::DispatchTrustedEvent(mozilla::dom::Document*, nsISupports*, nsTSubstring<char16_t> const&, mozilla::CanBubble, mozilla::Cancelable, mozilla::Composed, bool*) src/dom/base/nsContentUtils.cpp:4286:10
    #48 0x7f9f1da90516 in mozilla::dom::Document::DispatchContentLoadedEvents() src/dom/base/Document.cpp:7687:3
    #49 0x7f9f1db4ea6f in applyImpl<mozilla::dom::Document, void (mozilla::dom::Document::*)()> /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:1150:12
    #50 0x7f9f1db4ea6f in apply<mozilla::dom::Document, void (mozilla::dom::Document::*)()> /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:1156:12
    #51 0x7f9f1db4ea6f in mozilla::detail::RunnableMethodImpl<mozilla::dom::Document*, void (mozilla::dom::Document::*)(), true, (mozilla::RunnableKind)0>::Run() /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:1203:13
    #52 0x7f9f1a5ef2bf in mozilla::SchedulerGroup::Runnable::Run() src/xpcom/threads/SchedulerGroup.cpp:143:20
    #53 0x7f9f1a633072 in mozilla::RunnableTask::Run() src/xpcom/threads/TaskController.cpp:483:16
    #54 0x7f9f1a5ffce0 in mozilla::TaskController::DoExecuteNextTaskOnlyMainThreadInternal(mozilla::detail::BaseAutoLock<mozilla::Mutex&> const&) src/xpcom/threads/TaskController.cpp:786:26
    #55 0x7f9f1a5fd528 in mozilla::TaskController::ExecuteNextTaskOnlyMainThreadInternal(mozilla::detail::BaseAutoLock<mozilla::Mutex&> const&) src/xpcom/threads/TaskController.cpp:622:15
    #56 0x7f9f1a5fdc3d in mozilla::TaskController::ProcessPendingMTTask(bool) src/xpcom/threads/TaskController.cpp:406:36
    #57 0x7f9f1a63d0b1 in operator() src/xpcom/threads/TaskController.cpp:139:37
    #58 0x7f9f1a63d0b1 in mozilla::detail::RunnableFunction<mozilla::TaskController::InitializeInternal()::$_0>::Run() src/xpcom/threads/nsThreadUtils.h:534:5
    #59 0x7f9f1a61a458 in nsThread::ProcessNextEvent(bool, bool*) src/xpcom/threads/nsThread.cpp:1159:16
    #60 0x7f9f1a62519c in NS_ProcessNextEvent(nsIThread*, bool) src/xpcom/threads/nsThreadUtils.cpp:548:10
    #61 0x7f9f1b7e18bf in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) src/ipc/glue/MessagePump.cpp:85:21
    #62 0x7f9f1b6e9171 in RunInternal src/ipc/chromium/src/base/message_loop.cc:335:10
    #63 0x7f9f1b6e9171 in RunHandler src/ipc/chromium/src/base/message_loop.cc:328:3
    #64 0x7f9f1b6e9171 in MessageLoop::Run() src/ipc/chromium/src/base/message_loop.cc:310:3
    #65 0x7f9f21f894f7 in nsBaseAppShell::Run() src/widget/nsBaseAppShell.cpp:137:27
    #66 0x7f9f261fdc8f in XRE_RunAppShell() src/toolkit/xre/nsEmbedFunctions.cpp:911:20
    #67 0x7f9f1b6e9171 in RunInternal src/ipc/chromium/src/base/message_loop.cc:335:10
    #68 0x7f9f1b6e9171 in RunHandler src/ipc/chromium/src/base/message_loop.cc:328:3
    #69 0x7f9f1b6e9171 in MessageLoop::Run() src/ipc/chromium/src/base/message_loop.cc:310:3
    #70 0x7f9f261fd668 in XRE_InitChildProcess(int, char**, XREChildData const*) src/toolkit/xre/nsEmbedFunctions.cpp:743:34
    #71 0x55a7d341374d in content_process_main(mozilla::Bootstrap*, int, char**) src/browser/app/../../ipc/contentproc/plugin-container.cpp:57:28
    #72 0x55a7d3413b7d in main src/browser/app/nsBrowserApp.cpp:313:18
    #73 0x7f9f3bf720b2 in __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:308:16
    #74 0x55a7d3364a49 in _start (/home/user/workspace/browsers/m-c-20210604154219-fuzzing-asan-opt/firefox+0x5ba49)
Flags: in-testsuite?

Lee, I've cc'ed you on a few of these bugs that have come up in triage that all look quite similar. Fuzzing large allocs from skia canvas code.

Severity: -- → S3
Flags: needinfo?(lsalzman)
See Also: → 1715358, 1715360, 1715363
Flags: needinfo?(lsalzman)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: