Closed Bug 1426385 Opened 8 years ago Closed 4 years ago

Crash [@ js::CompartmentChecker::fail] with evaluate

Categories

(Core :: JavaScript Engine, defect, P2)

x86_64
Linux
defect

Tracking

()

RESOLVED FIXED
89 Branch
Tracking Status
firefox-esr60 --- wontfix
firefox-esr78 --- wontfix
firefox59 --- wontfix
firefox65 --- wontfix
firefox66 --- wontfix
firefox67 --- wontfix
firefox68 --- wontfix
firefox86 --- wontfix
firefox87 --- wontfix
firefox88 --- wontfix
firefox89 --- fixed

People

(Reporter: decoder, Assigned: tcampbell)

References

Details

(5 keywords, Whiteboard: [jsbugmon:testComment=10,origRev=8ec327de0ba7])

Crash Data

Attachments

(1 file)

The following testcase crashes on mozilla-central revision a235bf4868ab (build with --enable-posix-nspr-emulation --enable-valgrind --enable-gczeal --disable-tests --enable-stdcxx-compat --disable-profiling --enable-debug --enable-optimize, run with --fuzzing-safe): var someObject = {}; var evalOpt = { envChainObject: someObject }; test = (function() {})(); evalWithCache(test, __proto__); function evalWithCache(code, ctx) { ctx.global = newGlobal({}); } evaluate("assertEq(someVar, 1);", evalOpt); Backtrace: received signal SIGSEGV, Segmentation fault. 0x000000000056fb58 in js::CompartmentChecker::fail (c2=<optimized out>, c1=<optimized out>) at js/src/jscntxtinlines.h:40 #0 0x000000000056fb58 in js::CompartmentChecker::fail (c2=<optimized out>, c1=<optimized out>) at js/src/jscntxtinlines.h:40 #1 js::CompartmentChecker::check (c=<optimized out>, this=0x7fffffffc390) at js/src/jscntxtinlines.h:59 #2 js::CompartmentChecker::check (this=this@entry=0x7fffffffc390, obj=0x7ffff448e120) at js/src/jscntxtinlines.h:72 #3 0x0000000000b5fdc8 in js::CompartmentChecker::check<JSObject*> (handle=..., this=0x7fffffffc390) at js/src/jscntxtinlines.h:88 #4 js::assertSameCompartment<JS::MutableHandle<JSObject*> > (t1=..., cx=0x7ffff5f16000) at js/src/jscntxtinlines.h:217 #5 js::CreateObjectsForEnvironmentChain (cx=0x7ffff5f16000, chain=..., terminatingEnv=..., envObj=...) at js/src/vm/EnvironmentObject.cpp:3177 #6 0x00000000009a83c5 in CreateNonSyntacticEnvironmentChain (cx=0x7ffff5f16000, envChain=..., env=..., scope=scope@entry=...) at js/src/jsapi.cpp:3621 #7 0x00000000009b1c1b in ExecuteScript (cx=0x7ffff5f16000, envChain=..., scriptArg=..., rval=0x7ffff404f090) at js/src/jsapi.cpp:4667 #8 0x00000000009b1d7a in JS_ExecuteScript (cx=<optimized out>, envChain=..., scriptArg=..., scriptArg@entry=..., rval=...) at js/src/jsapi.cpp:4699 #9 0x000000000046ace9 in Evaluate (cx=0x7ffff5f16000, argc=<optimized out>, vp=<optimized out>) at js/src/shell/js.cpp:1820 #10 0x0000000000575ed1 in js::CallJSNative (cx=0x7ffff5f16000, native=0x46a230 <Evaluate(JSContext*, unsigned int, JS::Value*)>, args=...) at js/src/jscntxtinlines.h:291 [...] #24 main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at js/src/shell/js.cpp:9141 rax 0x0 0 rbx 0x7fffffffc390 140737488339856 rcx 0x7ffff6c282ad 140737333330605 rdx 0x0 0 rsi 0x7ffff6ef7770 140737336276848 rdi 0x7ffff6ef6540 140737336272192 rbp 0x7fffffffc330 140737488339760 rsp 0x7fffffffc310 140737488339728 r8 0x7ffff6ef7770 140737336276848 r9 0x7ffff7fe4780 140737354024832 r10 0x58 88 r11 0x7ffff6b9e7a0 140737332766624 r12 0x0 0 r13 0x200ce20 33607200 r14 0x0 0 r15 0x7ffff5f16000 140737319624704 rip 0x56fb58 <js::CompartmentChecker::check(JSObject*)+216> => 0x56fb58 <js::CompartmentChecker::check(JSObject*)+216>: movl $0x0,0x0 0x56fb63 <js::CompartmentChecker::check(JSObject*)+227>: ud2
Ugh. Ted, would you take a look please?
Flags: needinfo?(tcampbell)
Priority: -- → P1
Will take a look this afternoon. Most likely we need to detect the problem earlier and throw an exception to user when they call evaluate. Hopefully the story is better once I finish Bug 1406153, but I should be able to land a small fix in the meantime.
Reduced testcase isn't scary at all. jsshell-only. Already fixed in my local patches for Bug 1406153. I may defer this unless it becomes a fuzz blocker since the evaluate code is ugly and I'm rewriting it anyways. > var evalOpt = { > global: newGlobal(), > envChainObject: {} > }; > evaluate("", evalOpt); Will assign to myself to follow up on.
Assignee: nobody → tcampbell
Blocks: 1406153
Dropping priority to since jsshell-only.
Priority: P1 → P2
Whiteboard: [jsbugmon:update,bisect] → [jsbugmon:update]
JSBugMon: Bisection requested, result: autoBisect shows this is probably related to the following changeset: The first bad revision is: changeset: https://hg.mozilla.org/mozilla-central/rev/40aafceb5e48 user: Andrew McCreight date: Mon Aug 07 16:35:43 2017 -0700 summary: Bug 1388191 - Add way to test evaluation with envChain in the shell. r=jorendorff This iteration took 2.031 seconds to run.
Given comment 4 I'd like to remove the regression keyword so this isn't tracked in the regression triage meeting. I'll ni?(mccr8) based on comment 5.
Flags: needinfo?(continuation)
My patch just added a function that the test case uses. It seems reasonable to not mark it as a regression.
Flags: needinfo?(continuation)
Flags: needinfo?(tcampbell)
Whiteboard: [jsbugmon:update] → [jsbugmon:update,ignore]
var evalOpt = {
    global: newGlobal(),
    envChainObject: {}
};
evaluate("", evalOpt);

crashes js shell compiled with --enable-debug on m-c rev 8ec327de0ba7 using --fuzzing-safe --no-threads --no-baseline --no-ion --more-compartments at Hit MOZ_CRASH(*** Compartment mismatch 0x7f7c2939b9d0 vs. 0x7f7c2939b310 at argument 0) at js/src/vm/JSContext-inl.h:46

Whiteboard: [jsbugmon:update,ignore] → [jsbugmon:update,testComment=10,origRev=8ec327de0ba7]
Whiteboard: [jsbugmon:update,testComment=10,origRev=8ec327de0ba7] → [jsbugmon:testComment=10,origRev=8ec327de0ba7]

Bulk change for all regression bugs with status-firefox67 as 'fix-optional' to be marked 'affected' for status-firefox68.

This is a shell-only helper method that vaguely represents some complex Gecko
use-cases. At the very least we should not crash with scary compartment
errors.

Pushed by tcampbell@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/1a48b917af4a Properly wrap envChainObject to jsshell evaluate. r=mgaudet
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 89 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: