Closed Bug 1682612 Opened 5 years ago Closed 3 years ago

Assertion failure: false (dataSize == stride * imageSize.height), at /builds/worker/checkouts/gecko/dom/canvas/WebGLTextureUpload.cpp:80

Categories

(Core :: Graphics: CanvasWebGL, defect, P1)

defect

Tracking

()

VERIFIED FIXED
100 Branch
Tracking Status
firefox-esr91 --- wontfix
firefox86 --- wontfix
firefox93 --- wontfix
firefox94 --- wontfix
firefox95 --- wontfix
firefox96 --- wontfix
firefox98 --- wontfix
firefox99 --- wontfix
firefox100 --- verified

People

(Reporter: jkratzer, Assigned: jgilbert)

References

(Blocks 1 open bug)

Details

(Keywords: assertion, crash, testcase, Whiteboard: [bugmon:bisected,confirmed][fuzzblocker])

Crash Data

Attachments

(2 files, 1 obsolete file)

Attached file testcase.html

Testcase found while fuzzing mozilla-central rev f805f27183c3 (built with --enable-debug).

Assertion failure: false (dataSize == stride * imageSize.height), at /builds/worker/checkouts/gecko/dom/canvas/WebGLTextureUpload.cpp:80

    #0 0x7f4ccb159037 in mozilla::webgl::FromImageData(unsigned int, mozilla::avec3<unsigned int>, mozilla::dom::ImageData const&, mozilla::dom::TypedArray<unsigned char, &(js::UnwrapUint8ClampedArray(JSObject*)), &(JS_GetUint8ClampedArrayData(JSObject*, bool*, JS::AutoRequireNoGC const&)), &(js::GetUint8ClampedArrayLengthAndData(JSObject*, unsigned int*, bool*, unsigned char**)), &(JS_NewUint8ClampedArray(JSContext*, unsigned int))>*) /builds/worker/checkouts/gecko/dom/canvas/WebGLTextureUpload.cpp:80:3
    #1 0x7f4ccb0a7bac in operator() /builds/worker/checkouts/gecko/dom/canvas/ClientWebGLContext.cpp:3989:19
    #2 0x7f4ccb0a7bac in mozilla::ClientWebGLContext::TexImage(unsigned char, unsigned int, int, unsigned int, mozilla::avec3<int> const&, mozilla::avec3<int> const&, int, mozilla::webgl::PackingInfo const&, mozilla::TexImageSource const&) const /builds/worker/checkouts/gecko/dom/canvas/ClientWebGLContext.cpp:3941:15
    #3 0x7f4cca9321f2 in void mozilla::ClientWebGLContext::TexImage2D<mozilla::dom::ImageData>(unsigned int, int, unsigned int, int, int, int, unsigned int, unsigned int, mozilla::dom::ImageData const&, mozilla::ErrorResult&) const /builds/worker/checkouts/gecko/dom/canvas/ClientWebGLContext.h:1509:5
    #4 0x7f4cca9310c8 in mozilla::dom::WebGL2RenderingContext_Binding::texImage2D(JSContext*, JS::Handle<JSObject*>, void*, JSJitMethodCallArgs const&) /builds/worker/workspace/obj-build/dom/bindings/WebGL2RenderingContextBinding.cpp:2308:32
    #5 0x7f4ccafe071a in bool mozilla::dom::binding_detail::GenericMethod<mozilla::dom::binding_detail::NormalThisPolicy, mozilla::dom::binding_detail::ThrowExceptions>(JSContext*, unsigned int, JS::Value*) /builds/worker/checkouts/gecko/dom/bindings/BindingUtils.cpp:3231:13
    #6 0x7f4cce0030d1 in CallJSNative(JSContext*, bool (*)(JSContext*, unsigned int, JS::Value*), js::CallReason, JS::CallArgs const&) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:503:13
    #7 0x7f4cce00299c in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct, js::CallReason) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:594:12
    #8 0x7f4cce004113 in InternalCall(JSContext*, js::AnyInvokeArgs const&, js::CallReason) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:647:10
    #9 0x7f4ccdff85f2 in CallFromStack /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:651:10
    #10 0x7f4ccdff85f2 in Interpret(JSContext*, js::RunState&) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:3309:16
    #11 0x7f4ccdfef708 in js::RunScript(JSContext*, js::RunState&) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:473:13
    #12 0x7f4cce002906 in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct, js::CallReason) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:619:13
    #13 0x7f4cce004113 in InternalCall(JSContext*, js::AnyInvokeArgs const&, js::CallReason) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:647:10
    #14 0x7f4cce00434f in js::Call(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, js::AnyInvokeArgs const&, JS::MutableHandle<JS::Value>, js::CallReason) /builds/worker/checkouts/gecko/js/src/vm/Interpreter.cpp:664:8
    #15 0x7f4cce5abcab in JS::Call(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, JS::HandleValueArray const&, JS::MutableHandle<JS::Value>) /builds/worker/checkouts/gecko/js/src/jsapi.cpp:2842:10
    #16 0x7f4ccad11f7c 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
    #17 0x7f4ccb37f096 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
    #18 0x7f4ccb37edde in mozilla::EventListenerManager::HandleEventSubType(mozilla::EventListenerManager::Listener*, mozilla::dom::Event*, mozilla::dom::EventTarget*) /builds/worker/checkouts/gecko/dom/events/EventListenerManager.cpp:1089:43
    #19 0x7f4ccb37faa7 in mozilla::EventListenerManager::HandleEventInternal(nsPresContext*, mozilla::WidgetEvent*, mozilla::dom::Event**, mozilla::dom::EventTarget*, nsEventStatus*, bool) /builds/worker/checkouts/gecko/dom/events/EventListenerManager.cpp:1286:17
    #20 0x7f4ccb374d75 in HandleEvent /builds/worker/workspace/obj-build/dist/include/mozilla/EventListenerManager.h:390:5
    #21 0x7f4ccb374d75 in mozilla::EventTargetChainItem::HandleEvent(mozilla::EventChainPostVisitor&, mozilla::ELMCreationDetector&) /builds/worker/checkouts/gecko/dom/events/EventDispatcher.cpp:352:17
    #22 0x7f4ccb374323 in mozilla::EventTargetChainItem::HandleEventTargetChain(nsTArray<mozilla::EventTargetChainItem>&, mozilla::EventChainPostVisitor&, mozilla::EventDispatchingCallback*, mozilla::ELMCreationDetector&) /builds/worker/checkouts/gecko/dom/events/EventDispatcher.cpp:554:16
    #23 0x7f4ccb376e9d in mozilla::EventDispatcher::Dispatch(nsISupports*, nsPresContext*, mozilla::WidgetEvent*, mozilla::dom::Event*, nsEventStatus*, mozilla::EventDispatchingCallback*, nsTArray<mozilla::dom::EventTarget*>*) /builds/worker/checkouts/gecko/dom/events/EventDispatcher.cpp:1089:11
    #24 0x7f4ccb379916 in mozilla::EventDispatcher::DispatchDOMEvent(nsISupports*, mozilla::WidgetEvent*, mozilla::dom::Event*, nsPresContext*, nsEventStatus*) /builds/worker/checkouts/gecko/dom/events/EventDispatcher.cpp
    #25 0x7f4cc9e02463 in nsINode::DispatchEvent(mozilla::dom::Event&, mozilla::dom::CallerType, mozilla::ErrorResult&) /builds/worker/checkouts/gecko/dom/base/nsINode.cpp:1331:17
    #26 0x7f4cc9b1dd3a in nsContentUtils::DispatchEvent(mozilla::dom::Document*, nsISupports*, nsTSubstring<char16_t> const&, mozilla::CanBubble, mozilla::Cancelable, mozilla::Composed, mozilla::Trusted, bool*, mozilla::ChromeOnlyDispatch) /builds/worker/checkouts/gecko/dom/base/nsContentUtils.cpp:4212:28
    #27 0x7f4cc9b1dbc6 in nsContentUtils::DispatchTrustedEvent(mozilla::dom::Document*, nsISupports*, nsTSubstring<char16_t> const&, mozilla::CanBubble, mozilla::Cancelable, mozilla::Composed, bool*) /builds/worker/checkouts/gecko/dom/base/nsContentUtils.cpp:4182:10
    #28 0x7f4cc9c852e3 in mozilla::dom::Document::DispatchContentLoadedEvents() /builds/worker/checkouts/gecko/dom/base/Document.cpp:7488:3
    #29 0x7f4cc9cf69d6 in applyImpl<mozilla::dom::Document, void (mozilla::dom::Document::*)()> /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:1148:12
    #30 0x7f4cc9cf69d6 in apply<mozilla::dom::Document, void (mozilla::dom::Document::*)()> /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:1154:12
    #31 0x7f4cc9cf69d6 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:1201:13
    #32 0x7f4cc80935e2 in mozilla::SchedulerGroup::Runnable::Run() /builds/worker/checkouts/gecko/xpcom/threads/SchedulerGroup.cpp:146:20
    #33 0x7f4cc809964f in mozilla::RunnableTask::Run() /builds/worker/checkouts/gecko/xpcom/threads/TaskController.cpp:459:16
    #34 0x7f4cc8097c7a in mozilla::TaskController::DoExecuteNextTaskOnlyMainThreadInternal(mozilla::detail::BaseAutoLock<mozilla::Mutex&> const&) /builds/worker/checkouts/gecko/xpcom/threads/TaskController.cpp:739:26
    #35 0x7f4cc8096d24 in mozilla::TaskController::ExecuteNextTaskOnlyMainThreadInternal(mozilla::detail::BaseAutoLock<mozilla::Mutex&> const&) /builds/worker/checkouts/gecko/xpcom/threads/TaskController.cpp:598:15
    #36 0x7f4cc8096ed7 in mozilla::TaskController::ProcessPendingMTTask(bool) /builds/worker/checkouts/gecko/xpcom/threads/TaskController.cpp:382:36
    #37 0x7f4cc809cf16 in operator() /builds/worker/checkouts/gecko/xpcom/threads/TaskController.cpp:123:37
    #38 0x7f4cc809cf16 in mozilla::detail::RunnableFunction<mozilla::TaskController::InitializeInternal()::$_3>::Run() /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:534:5
    #39 0x7f4cc80ae5f5 in nsThread::ProcessNextEvent(bool, bool*) /builds/worker/checkouts/gecko/xpcom/threads/nsThread.cpp:1200:14
    #40 0x7f4cc80b46ba in NS_ProcessNextEvent(nsIThread*, bool) /builds/worker/checkouts/gecko/xpcom/threads/nsThreadUtils.cpp:548:10
    #41 0x7f4cc89bf836 in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) /builds/worker/checkouts/gecko/ipc/glue/MessagePump.cpp:87:21
    #42 0x7f4cc892b8d3 in MessageLoop::RunInternal() /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:334:10
    #43 0x7f4cc892b7ed in RunHandler /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:327:3
    #44 0x7f4cc892b7ed in MessageLoop::Run() /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:309:3
    #45 0x7f4ccc6b4f58 in nsBaseAppShell::Run() /builds/worker/checkouts/gecko/widget/nsBaseAppShell.cpp:137:27
    #46 0x7f4ccdec6a43 in XRE_RunAppShell() /builds/worker/checkouts/gecko/toolkit/xre/nsEmbedFunctions.cpp:902:20
    #47 0x7f4cc89c071c in mozilla::ipc::MessagePumpForChildProcess::Run(base::MessagePump::Delegate*) /builds/worker/checkouts/gecko/ipc/glue/MessagePump.cpp:237:9
    #48 0x7f4cc892b8d3 in MessageLoop::RunInternal() /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:334:10
    #49 0x7f4cc892b7ed in RunHandler /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:327:3
    #50 0x7f4cc892b7ed in MessageLoop::Run() /builds/worker/checkouts/gecko/ipc/chromium/src/base/message_loop.cc:309:3
    #51 0x7f4ccdec6618 in XRE_InitChildProcess(int, char**, XREChildData const*) /builds/worker/checkouts/gecko/toolkit/xre/nsEmbedFunctions.cpp:733:34
    #52 0x55d93ab41d96 in content_process_main /builds/worker/checkouts/gecko/browser/app/../../ipc/contentproc/plugin-container.cpp:57:28
    #53 0x55d93ab41d96 in main /builds/worker/checkouts/gecko/browser/app/nsBrowserApp.cpp:305:18
    #54 0x7f4cdccda0b2 in __libc_start_main /build/glibc-ZN95T4/glibc-2.31/csu/../csu/libc-start.c:308:16
Flags: in-testsuite?

Bugmon Analysis:
Verified bug as reproducible on mozilla-central 20201215213427-914398229db8.
The bug appears to have been introduced in the following build range:

Start: dc056be018fe8400010ef3169ff13ff739758a33 (20200721215127)
End: 6dfc866efa7af78eaa72d42b806dc118ccf8c8ce (20200722043241)
Pushlog: https://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=dc056be018fe8400010ef3169ff13ff739758a33&tochange=6dfc866efa7af78eaa72d42b806dc118ccf8c8ce

Whiteboard: [bugmon:confirm] → [bugmon:bisected,confirmed]
Crash Signature: [@ mozilla::webgl::FromImageData ]
Keywords: crash
No longer blocks: domino
Depends on: domino
Blocks: domino
No longer depends on: domino
Assignee: nobody → jgilbert
Severity: -- → S2

This issue is triggered frequently by fuzzers. Marking as fuzzblocker.

Whiteboard: [bugmon:bisected,confirmed] → [bugmon:bisected,confirmed][fuzzblocker]

It looks like we're hitting this because the width and height parameters to TexImage2D are 0

Severity: S2 → S3
Priority: -- → P1

Yeah the test case passes some strings but you can modify it to pass zero width and height and it will repro as well. I didn't see anything about returning errors in this case in the spec so I guess we can check and early return maybe in ClientWebGLContext::TexImage.

  MOZ_RELEASE_ASSERT(scopedArr->Init(imageData.GetDataObject()));
  scopedArr->ComputeState();
  const size_t dataSize = scopedArr->Length(); // 0
  const auto data = reinterpret_cast<uint8_t*>(scopedArr->Data()); // null

  const gfx::IntSize imageISize(imageData.Width(), imageData.Height()); // {1,1}  (!!!)
  const auto imageUSize = *uvec2::FromSize(imageISize);
  const size_t stride = imageUSize.x * 4; // 4
  const gfx::SurfaceFormat surfFormat = gfx::SurfaceFormat::R8G8B8A8;
  MOZ_ALWAYS_TRUE(dataSize == stride * imageUSize.y); // 0 == 4 (!!!)

This is certainly what the assert was supposed to catch. I'm not sure why we're not getting data from it.

        const buffer_2 = new ArrayBuffer(4)
        const arr_1 = new Uint8ClampedArray(buffer_2)
        const data = new ImageData(arr_1, 1)
[...]
        context.texImage2D(context.TEXTURE_CUBE_MAP_NEGATIVE_X, 1, 'context.context.RGB', 'data.width', 'data.height', 0, 'context.context.RGB', 'context.context.UNSIGNED_SHORT_5_6_5', data)

https://developer.mozilla.org/en-US/docs/Web/API/ImageData/ImageData

new ImageData(width, height);
new ImageData(width, height, settings);
new ImageData(dataArray, width);
new ImageData(dataArray, width, height);
new ImageData(dataArray, width, height, settings);

height

An unsigned long representing the height of the image. This value is optional if an array is given: the height will be inferred from the array's size and the given width.

Is the arraybuffer lazily initialized, and we haven't incurred initialization yet?

I can certainly fix this, but it seems very weird that each reader of TypedArray needs to handle the uninitialized-value case.

Oh, postMessage is Transferring the ArrayBuffer, leaving it neutered.
I wondered if ImageData.data should actually be a reference like that, when I would expect a copy of the ArrayBuffer when invoking the ctor, but it looks like it's the same object, though it seems to not have the same expandos?

Comment on attachment 9268721 [details]
testcase-1682612-imagedata-2.html (=== true but different expandos)

I kept looking for an error, but couldn't find one.
I did indeed miss that I was saying "data.data.buffer.is_buffer_2" but displaying data.data.is_buffer_2.
My kingdom for a better js expr assertion/output approach.

Attachment #9268721 - Attachment is obsolete: true
Pushed by jgilbert@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/e17ff252de56 Check for ArrayBuffer Detach/Transfer in texImage2D(ImageData). r=gfx-reviewers,aosmond
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 100 Branch

Bugmon Analysis
Verified bug as fixed on rev mozilla-central 20220322042758-eee8f4778c79.
Removing bugmon keyword as no further action possible. Please review the bug and re-add the keyword for further analysis.

Status: RESOLVED → VERIFIED
Keywords: bugmon

:jgilbert, since this bug contains a bisection range, could you fill (if possible) the regressed_by field?
For more information, please visit auto_nag documentation.

Flags: needinfo?(jgilbert)

No, this seems like a general early webgl ipc bug, hard to usefully pin down a regressor.

Flags: needinfo?(jgilbert)
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: