Closed Bug 1780042 Opened 8 months ago Closed 8 months ago

Assertion failure: false (MOZ_ASSERT_UNREACHABLE: Must have a principal here), at /dom/canvas/CanvasUtils.cpp:248

Categories

(Core :: Graphics: Canvas2D, defect, P3)

x86_64
Linux
defect

Tracking

()

VERIFIED FIXED
105 Branch
Tracking Status
firefox105 --- verified

People

(Reporter: jkratzer, Assigned: aosmond)

References

(Blocks 1 open bug)

Details

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

Attachments

(2 files)

Testcase found while fuzzing mozilla-central rev 0ac3dabcf588 (built with: --enable-debug --enable-fuzzing).

Testcase can be reproduced using the following commands:

$ pip install fuzzfetch grizzly-framework
$ python -m fuzzfetch --build 0ac3dabcf588 --debug --fuzzing -n firefox
$ python -m grizzly.replay ./firefox/firefox testcase.html
Assertion failure: false (MOZ_ASSERT_UNREACHABLE: Must have a principal here), at /dom/canvas/CanvasUtils.cpp:248

    ==3175914==ERROR: UndefinedBehaviorSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7f855d652e4e bp 0x7ffecfa1d1e0 sp 0x7ffecfa1d1a0 T3175914)
    ==3175914==The signal is caused by a WRITE memory access.
    ==3175914==Hint: address points to the zero page.
        #0 0x7f855d652e4e in mozilla::CanvasUtils::DoDrawImageSecurityCheck(mozilla::dom::HTMLCanvasElement*, nsIPrincipal*, bool, bool) /dom/canvas/CanvasUtils.cpp:248:5
        #1 0x7f855d6377d4 in mozilla::dom::CanvasGeneralPattern::ForStyle(mozilla::dom::CanvasRenderingContext2D*, mozilla::dom::CanvasRenderingContext2D::Style, mozilla::gfx::DrawTarget*) /dom/canvas/CanvasRenderingContext2D.cpp:307:13
        #2 0x7f855d63abfc in mozilla::dom::CanvasRenderingContext2D::Stroke() /dom/canvas/CanvasRenderingContext2D.cpp:3023:40
        #3 0x7f855caa6564 in mozilla::dom::CanvasRenderingContext2D_Binding::stroke(JSContext*, JS::Handle<JSObject*>, void*, JSJitMethodCallArgs const&) /builds/worker/workspace/obj-build/dom/bindings/CanvasRenderingContext2DBinding.cpp:3060:28
        #4 0x7f855d558efc in bool mozilla::dom::binding_detail::GenericMethod<mozilla::dom::binding_detail::NormalThisPolicy, mozilla::dom::binding_detail::ThrowExceptions>(JSContext*, unsigned int, JS::Value*) /dom/bindings/BindingUtils.cpp:3285:13
        #5 0x7f8562a5fc30 in CallJSNative(JSContext*, bool (*)(JSContext*, unsigned int, JS::Value*), js::CallReason, JS::CallArgs const&) /js/src/vm/Interpreter.cpp:417:13
        #6 0x7f8562a5f49a in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct, js::CallReason) /js/src/vm/Interpreter.cpp:504:12
        #7 0x7f8562a5698c in CallFromStack /js/src/vm/Interpreter.cpp:575:10
        #8 0x7f8562a5698c in Interpret(JSContext*, js::RunState&) /js/src/vm/Interpreter.cpp:3313:16
        #9 0x7f8562a4dd02 in js::RunScript(JSContext*, js::RunState&) /js/src/vm/Interpreter.cpp:389:13
        #10 0x7f8562a5f396 in js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct, js::CallReason) /js/src/vm/Interpreter.cpp:536:13
        #11 0x7f8562a60958 in js::Call(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, js::AnyInvokeArgs const&, JS::MutableHandle<JS::Value>, js::CallReason) /js/src/vm/Interpreter.cpp:602:8
        #12 0x7f8561714311 in JS::Call(JSContext*, JS::Handle<JS::Value>, JS::Handle<JS::Value>, JS::HandleValueArray const&, JS::MutableHandle<JS::Value>) /js/src/vm/CallAndConstruct.cpp:117:10
        #13 0x7f855d2746b9 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:62:8
        #14 0x7f855dad0d46 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
        #15 0x7f855dad0a6d in mozilla::EventListenerManager::HandleEventSubType(mozilla::EventListenerManager::Listener*, mozilla::dom::Event*, mozilla::dom::EventTarget*) /dom/events/EventListenerManager.cpp:1310:43
        #16 0x7f855dad1717 in mozilla::EventListenerManager::HandleEventInternal(nsPresContext*, mozilla::WidgetEvent*, mozilla::dom::Event**, mozilla::dom::EventTarget*, nsEventStatus*, bool) /dom/events/EventListenerManager.cpp:1506:17
        #17 0x7f855dac6624 in HandleEvent /dom/events/EventListenerManager.h:395:5
        #18 0x7f855dac6624 in mozilla::EventTargetChainItem::HandleEvent(mozilla::EventChainPostVisitor&, mozilla::ELMCreationDetector&) /dom/events/EventDispatcher.cpp:348:17
        #19 0x7f855dac5b72 in mozilla::EventTargetChainItem::HandleEventTargetChain(nsTArray<mozilla::EventTargetChainItem>&, mozilla::EventChainPostVisitor&, mozilla::EventDispatchingCallback*, mozilla::ELMCreationDetector&) /dom/events/EventDispatcher.cpp:550:16
        #20 0x7f855dac8411 in mozilla::EventDispatcher::Dispatch(nsISupports*, nsPresContext*, mozilla::WidgetEvent*, mozilla::dom::Event*, nsEventStatus*, mozilla::EventDispatchingCallback*, nsTArray<mozilla::dom::EventTarget*>*) /dom/events/EventDispatcher.cpp:1119:11
        #21 0x7f855dacaeb6 in mozilla::EventDispatcher::DispatchDOMEvent(nsISupports*, mozilla::WidgetEvent*, mozilla::dom::Event*, nsPresContext*, nsEventStatus*) /dom/events/EventDispatcher.cpp
        #22 0x7f855c1b9f1d in nsINode::DispatchEvent(mozilla::dom::Event&, mozilla::dom::CallerType, mozilla::ErrorResult&) /dom/base/nsINode.cpp:1366:17
        #23 0x7f855bcfa95a in nsContentUtils::DispatchEvent(mozilla::dom::Document*, nsISupports*, nsTSubstring<char16_t> const&, mozilla::CanBubble, mozilla::Cancelable, mozilla::Composed, mozilla::Trusted, bool*, mozilla::ChromeOnlyDispatch) /dom/base/nsContentUtils.cpp:4487:28
        #24 0x7f855bcfa757 in nsContentUtils::DispatchTrustedEvent(mozilla::dom::Document*, nsISupports*, nsTSubstring<char16_t> const&, mozilla::CanBubble, mozilla::Cancelable, mozilla::Composed, bool*) /dom/base/nsContentUtils.cpp:4457:10
        #25 0x7f855bf365ff in mozilla::dom::Document::DispatchContentLoadedEvents() /dom/base/Document.cpp:8032:3
        #26 0x7f855bfea32b in applyImpl<mozilla::dom::Document, void (mozilla::dom::Document::*)()> /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:1147:12
        #27 0x7f855bfea32b in apply<mozilla::dom::Document, void (mozilla::dom::Document::*)()> /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:1153:12
        #28 0x7f855bfea32b 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:1200:13
        #29 0x7f855a569cc2 in mozilla::SchedulerGroup::Runnable::Run() /xpcom/threads/SchedulerGroup.cpp:140:20
        #30 0x7f855a59b97e in mozilla::RunnableTask::Run() /xpcom/threads/TaskController.cpp:538:16
        #31 0x7f855a5740a9 in mozilla::TaskController::DoExecuteNextTaskOnlyMainThreadInternal(mozilla::detail::BaseAutoLock<mozilla::Mutex&> const&) /xpcom/threads/TaskController.cpp:851:26
        #32 0x7f855a572c33 in mozilla::TaskController::ExecuteNextTaskOnlyMainThreadInternal(mozilla::detail::BaseAutoLock<mozilla::Mutex&> const&) /xpcom/threads/TaskController.cpp:683:15
        #33 0x7f855a572ea3 in mozilla::TaskController::ProcessPendingMTTask(bool) /xpcom/threads/TaskController.cpp:461:36
        #34 0x7f855a59f1d6 in operator() /xpcom/threads/TaskController.cpp:187:37
        #35 0x7f855a59f1d6 in mozilla::detail::RunnableFunction<mozilla::TaskController::InitializeInternal()::$_0>::Run() /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:531:5
        #36 0x7f855a588aef in nsThread::ProcessNextEvent(bool, bool*) /xpcom/threads/nsThread.cpp:1205:16
        #37 0x7f855a58f0fd in NS_ProcessNextEvent(nsIThread*, bool) /xpcom/threads/nsThreadUtils.cpp:465:10
        #38 0x7f855b15cf76 in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) /ipc/glue/MessagePump.cpp:85:21
        #39 0x7f855b083397 in MessageLoop::RunInternal() /ipc/chromium/src/base/message_loop.cc:380:10
        #40 0x7f855b0832a2 in RunHandler /ipc/chromium/src/base/message_loop.cc:373:3
        #41 0x7f855b0832a2 in MessageLoop::Run() /ipc/chromium/src/base/message_loop.cc:355:3
        #42 0x7f855f32c8f8 in nsBaseAppShell::Run() /widget/nsBaseAppShell.cpp:150:27
        #43 0x7f8561453cab in XRE_RunAppShell() /toolkit/xre/nsEmbedFunctions.cpp:875:20
        #44 0x7f855b15de6a in mozilla::ipc::MessagePumpForChildProcess::Run(base::MessagePump::Delegate*) /ipc/glue/MessagePump.cpp:235:9
        #45 0x7f855b083397 in MessageLoop::RunInternal() /ipc/chromium/src/base/message_loop.cc:380:10
        #46 0x7f855b0832a2 in RunHandler /ipc/chromium/src/base/message_loop.cc:373:3
        #47 0x7f855b0832a2 in MessageLoop::Run() /ipc/chromium/src/base/message_loop.cc:355:3
        #48 0x7f85614532cc in XRE_InitChildProcess(int, char**, XREChildData const*) /toolkit/xre/nsEmbedFunctions.cpp:734:34
        #49 0x55c0114c9110 in content_process_main /browser/app/../../ipc/contentproc/plugin-container.cpp:57:28
        #50 0x55c0114c9110 in main /browser/app/nsBrowserApp.cpp:338:18
        #51 0x7f8570cd7082 in __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:308:16
        #52 0x55c01149eebc in _start (/home/jkratzer/builds/mc-debug/firefox-bin+0x15ebc) (BuildId: a5a643de37db9b352fa1f14641c51027bda29ef4)
    
    UndefinedBehaviorSanitizer can not provide additional info.
    SUMMARY: UndefinedBehaviorSanitizer: SEGV /dom/canvas/CanvasUtils.cpp:248:5 in mozilla::CanvasUtils::DoDrawImageSecurityCheck(mozilla::dom::HTMLCanvasElement*, nsIPrincipal*, bool, bool)
    ==3175914==ABORTING
Attached file Testcase

Bugmon Analysis
Verified bug as reproducible on mozilla-central 20220718132938-674d4b94e8b3.
Unable to bisect testcase (Testcase reproduces on start build!):

Start: c75f4ae449378437bbd05fd00bfdbe1bf5e125de (20210719093934)
End: 0ac3dabcf588387aba58cdf2ff7400d05aa8ccd0 (20220717090304)
BuildFlags: BuildFlags(asan=False, tsan=False, debug=True, fuzzing=True, coverage=False, valgrind=False, no_opt=False, fuzzilli=False, nyx=False)

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

The assert here is a debug assert, the principal passed to DoDrawImageSecurityCheck is null, and there's a safe return. Probably some sort of content destruction race? Call is triggered by a canvas CanvasRenderingContext2D::Stroke call.

Severity: -- → S4
Flags: needinfo?(lsalzman)
Priority: -- → P3
Flags: needinfo?(lsalzman) → needinfo?(aosmond)
Assignee: nobody → aosmond
Status: NEW → ASSIGNED
Flags: needinfo?(aosmond)
Pushed by aosmond@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/ad83f5251083
Set CanvasPattern principal for main thread OffscreenCanvas. r=lsalzman

Backed out for causing wpt failures on nsICanvasRenderingContextInternal.cpp

Backout link

Push with failures

Failure log

Flags: needinfo?(aosmond)
Pushed by aosmond@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/6846439a1bb1
Set CanvasPattern principal for main thread OffscreenCanvas. r=lsalzman
Status: ASSIGNED → RESOLVED
Closed: 8 months ago
Resolution: --- → FIXED
Target Milestone: --- → 105 Branch

Bugmon Analysis
Verified bug as fixed on rev mozilla-central 20220802214455-3d354d73dc2a.
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
Flags: needinfo?(aosmond)
You need to log in before you can comment on or make changes to this bug.