Closed Bug 1816254 Opened 1 year ago Closed 1 year ago

Assertion failure: vp.isObject(), at vm/Compartment-inl.h:78

Categories

(Core :: JavaScript Engine, defect, P2)

defect

Tracking

()

RESOLVED DUPLICATE of bug 1826230

People

(Reporter: lukas.bernhard, Assigned: bthrall)

References

(Blocks 2 open bugs)

Details

Steps to reproduce:

On commit 1d6e2f82287c298f77f21ad0f62f1aed6155577c the attached sample crashes in the debugger api when invoked via obj-x86_64-pc-linux-gnu/dist/bin/js --fuzzing-safe crash.js

InternalError.cause = InternalError;
const v2 = InternalError(this, InternalError);
const v3 = [];
function f4() {
    throw v2;
}
Object.defineProperty(v2, "cause", { get: () => undefined });
Object.defineProperty(v3, "matchAll", { get: f4 });
with (v3) {
    function f8(a9) {
        function f11() {
            return a9;
        }
        Object.defineProperty(a9, "sameZoneAs", { get: f11 });
        this.newGlobal(a9).Debugger(a9).getNewestFrame().environment.find("matchAll").getVariable("matchAll");
        return a9;
    }
    new Promise(f8);
}
#0  0x00005555573be028 in JS::Compartment::wrap (this=0x7ffff7403f50, cx=0x7ffff742f100, vp=...) at js/src/vm/Compartment-inl.h:78
#1  0x0000555557f5f42d in js::CopyErrorObject (cx=0x7ffff742f100, err=...) at js/src/jsexn.cpp:729
#2  0x0000555557fd8d64 in js::ErrorCopier::~ErrorCopier (this=0x7fffffff6990) at js/src/proxy/Wrapper.cpp:450
#3  0x0000555558073246 in js::DebuggerEnvironment::getVariable (cx=0x7ffff742f100, environment=..., id=..., result=...)
    at js/src/debugger/Environment.cpp:606
#4  0x0000555558072e30 in js::DebuggerEnvironment::CallData::getVariableMethod (this=0x7fffffff6af8) at js/src/debugger/Environment.cpp:324
#5  0x000055555809f10f in js::DebuggerEnvironment::CallData::ToNative<&js::DebuggerEnvironment::CallData::getVariableMethod> (cx=0x7ffff742f100, argc=1, vp=0x7fffffff6fd0)
    at js/src/debugger/Environment.cpp:140
#6  0x00005555575603ce in CallJSNative (cx=0x7ffff742f100, 
    native=0x55555809efb0 <js::DebuggerEnvironment::CallData::ToNative<&js::DebuggerEnvironment::CallData::getVariableMethod>(JSContext*, unsigned int, JS::Value*)>, 
    reason=js::CallReason::Call, args=...) at js/src/vm/Interpreter.cpp:459
#7  0x000055555755fc0d in js::InternalCallOrConstruct (cx=0x7ffff742f100, args=..., construct=js::NO_CONSTRUCT, reason=js::CallReason::Call)
    at js/src/vm/Interpreter.cpp:547
#8  0x0000555557560fa1 in InternalCall (cx=0x7ffff742f100, args=..., reason=js::CallReason::Call) at js/src/vm/Interpreter.cpp:614
#9  0x00005555575611e5 in js::Call (cx=0x7ffff742f100, fval=..., thisv=..., args=..., rval=..., reason=js::CallReason::Call)
    at js/src/vm/Interpreter.cpp:646
#10 0x0000555557fd6468 in js::ForwardingProxyHandler::call (this=0x5555598f1990 <js::CrossCompartmentWrapper::singleton>, cx=0x7ffff742f100, proxy=..., args=...)
    at js/src/proxy/Wrapper.cpp:168
#11 0x0000555557fab195 in js::CrossCompartmentWrapper::call (this=0x5555598f1990 <js::CrossCompartmentWrapper::singleton>, cx=0x7ffff742f100, wrapper=..., args=...)
    at js/src/proxy/CrossCompartmentWrapper.cpp:229
#12 0x0000555557fc5d21 in js::Proxy::call (cx=0x7ffff742f100, proxy=..., args=...) at js/src/proxy/Proxy.cpp:676
#13 0x000055555755f89a in js::InternalCallOrConstruct (cx=0x7ffff742f100, args=..., construct=js::NO_CONSTRUCT, reason=js::CallReason::Call)
    at js/src/vm/Interpreter.cpp:527
#14 0x0000555557560fa1 in InternalCall (cx=0x7ffff742f100, args=..., reason=js::CallReason::Call) at js/src/vm/Interpreter.cpp:614
#15 0x0000555557560d65 in js::CallFromStack (cx=0x7ffff742f100, args=..., reason=js::CallReason::Call) at js/src/vm/Interpreter.cpp:619
#16 0x0000555557551a94 in Interpret (cx=0x7ffff742f100, state=...) at js/src/vm/Interpreter.cpp:3362
#17 0x0000555557543b70 in js::RunScript (cx=0x7ffff742f100, state=...) at js/src/vm/Interpreter.cpp:431
#18 0x000055555755fecc in js::InternalCallOrConstruct (cx=0x7ffff742f100, args=..., construct=js::NO_CONSTRUCT, reason=js::CallReason::Call)
    at js/src/vm/Interpreter.cpp:579
#19 0x0000555557560fa1 in InternalCall (cx=0x7ffff742f100, args=..., reason=js::CallReason::Call) at js/src/vm/Interpreter.cpp:614
#20 0x00005555575611e5 in js::Call (cx=0x7ffff742f100, fval=..., thisv=..., args=..., rval=..., reason=js::CallReason::Call)
    at js/src/vm/Interpreter.cpp:646
#21 0x0000555557ab8ca5 in js::PromiseObject::create (cx=0x7ffff742f100, executor=..., proto=..., needsWrapping=false)
    at js/src/builtin/Promise.cpp:2868
#22 0x0000555557ae48f9 in PromiseConstructor (cx=0x7ffff742f100, argc=1, vp=0x7ffff4cec098) at js/src/builtin/Promise.cpp:2779
#23 0x00005555575603ce in CallJSNative (cx=0x7ffff742f100, native=0x555557ae4250 <PromiseConstructor(JSContext*, unsigned int, JS::Value*)>, reason=js::CallReason::Call, 
    args=...) at js/src/vm/Interpreter.cpp:459
#24 0x0000555557577017 in CallJSNativeConstructor (cx=0x7ffff742f100, native=0x555557ae4250 <PromiseConstructor(JSContext*, unsigned int, JS::Value*)>, args=...)
    at js/src/vm/Interpreter.cpp:475
#25 0x0000555557561c10 in InternalConstruct (cx=0x7ffff742f100, args=..., reason=js::CallReason::Call) at js/src/vm/Interpreter.cpp:675
#26 0x0000555557561553 in js::ConstructFromStack (cx=0x7ffff742f100, args=..., reason=js::CallReason::Call) at js/src/vm/Interpreter.cpp:722
#27 0x000055555755183a in Interpret (cx=0x7ffff742f100, state=...) at js/src/vm/Interpreter.cpp:3347
#28 0x0000555557543b70 in js::RunScript (cx=0x7ffff742f100, state=...) at js/src/vm/Interpreter.cpp:431
Component: Untriaged → JavaScript Engine
Product: Firefox → Core
Severity: -- → S3
Priority: -- → P2
Blocks: sm-runtime

I'll take a look at this.

Flags: needinfo?(bthrall)

It looks like this is a problem with copying the thrown Error across the compartment boundary.

Here is a simpler script to reproduce the problem:

Error.cause = undefined;
const error = Error(this, Error);
const arr = [];
Object.defineProperty(error, "cause", { get: () => undefined });
Object.defineProperty(arr, "matchAll", { get: () => { throw error; } });
with (arr) {
    let frame = this.newGlobal({ sameZoneAs: this }).Debugger(this).getNewestFrame();
    let matchAllProp = frame.environment.find("matchAll");
    matchAllProp.getVariable("matchAll");
}
Assignee: nobody → bthrall
Status: NEW → ASSIGNED
Flags: needinfo?(bthrall)
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Duplicate of bug: 1826230
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.