Closed Bug 1300904 Opened 10 years ago Closed 10 years ago

Assertion failure: !isFrozen(), at js/src/vm/NativeObject.h:298

Categories

(Core :: JavaScript Engine, defect)

x86_64
macOS
defect
Not set
critical

Tracking

()

RESOLVED FIXED
mozilla51
Tracking Status
firefox51 --- fixed

People

(Reporter: gkw, Assigned: jandem)

References

Details

(Keywords: assertion, bugmon, testcase, Whiteboard: [jsbugmon:update])

Attachments

(2 files, 1 obsolete file)

The following testcase crashes on mozilla-central revision 394f02edb7cb (build with --enable-debug --enable-more-deterministic, run with --fuzzing-safe --no-threads --no-baseline --no-ion): Object.getOwnPropertyNames(this); oomTest(function() { this["0"] = function() {}; Object.freeze(this); }) Backtrace: 0 js-dbg-64-dm-clang-darwin-394f02edb7cb 0x00000001050e5911 js::ObjectElements::FreezeElements(js::ExclusiveContext*, JS::Handle<js::NativeObject*>) + 145 (NativeObject.h:298) 1 js-dbg-64-dm-clang-darwin-394f02edb7cb 0x0000000104f0956a js::PreventExtensions(JSContext*, JS::Handle<JSObject*>, JS::ObjectOpResult&, js::IntegrityLevel) + 554 (jsobj.cpp:2618) 2 js-dbg-64-dm-clang-darwin-394f02edb7cb 0x0000000104efe315 js::SetIntegrityLevel(JSContext*, JS::Handle<JSObject*>, js::IntegrityLevel) + 117 (jsobj.cpp:2634) 3 js-dbg-64-dm-clang-darwin-394f02edb7cb 0x00000001052add77 obj_freeze(JSContext*, unsigned int, JS::Value*) + 231 (RootingAPI.h:706) 4 js-dbg-64-dm-clang-darwin-394f02edb7cb 0x00000001050d706c js::InternalCallOrConstruct(JSContext*, JS::CallArgs const&, js::MaybeConstruct) + 716 (jscntxtinlines.h:236) /snip For detailed crash information, see attachment.
autoBisect shows this is probably related to the following changeset: The first bad revision is: changeset: https://hg.mozilla.org/mozilla-central/rev/f95b25ae990d user: Leo Gaspard date: Mon Aug 29 15:00:35 2016 -0700 summary: Bug 1283334 - Part 1: Do not sparsify dense arrays when freezing - Interpreter. r=jandem Leo, is bug 1283334 a likely regressor?
Blocks: 1283334
Flags: needinfo?(leo)
Yes, bug 1283334 is a likely regressor as it added this assertion. However, I neither understand the reason why this test fails, nor why the `Object.getOwnPropertyNames(this);` is required to reproduce while it doesn't seem supposed to do anything modifying `this`, as far as I can tell from reading [1]. That said, I originally added this assertion after noticing that running `a = [0, 1, 2]; Object.freeze(a); Object.freeze(a);` did not call the function twice. I do not completely understand why, and if `PreventExtensions` is called multiple times on the same object it may call `ObjectElements::freeze()` twice, which would trigger the assertion without necessarily being an unwanted behaviour. However, this test case does things I don't fully understand, and in particular its non-reproducibility without the `Object.getOwnPropertyNames(this);` makes me think something fishy is going on. Jan, hopefully you understand better than me why this is so, whether the assertion is "rightly" triggered or not, and whether just removing it would be safe? [1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames
Flags: needinfo?(leo) → needinfo?(jdemooij)
It's also reproducible for me when I replace `Object.getOwnPropertyNames(this);` with `Intl;` to ensure the Intl object is resolved before calling oomTest. ``` Intl; this[0] = null; oomTest(function() { Object.freeze(this); }); ```
https://dxr.mozilla.org/mozilla-central/source/js/src/jsobj.cpp#2625 is never executed in the assertion case, which means the test in https://dxr.mozilla.org/mozilla-central/source/js/src/jsobj.cpp#2599 always fails and therefore https://dxr.mozilla.org/mozilla-central/source/js/src/jsobj.cpp#2618 is executed multiple times on the global object.
Attached patch Patch (obsolete) — — Splinter Review
André's analysis is correct. This patch just resets the element's frozen flag if we failed to set the non-extensible BaseShape flag.
Assignee: nobody → jdemooij
Status: NEW → ASSIGNED
Flags: needinfo?(jdemooij)
Attachment #8790270 - Flags: review?(leo)
Attached patch Patch — — Splinter Review
Attachment #8790270 - Attachment is obsolete: true
Attachment #8790270 - Flags: review?(leo)
Attachment #8790271 - Flags: review?(leo)
Comment on attachment 8790271 [details] [diff] [review] Patch Review of attachment 8790271 [details] [diff] [review]: ----------------------------------------------------------------- Thanks to you two!
Attachment #8790271 - Flags: review?(leo) → review+
Pushed by jandemooij@gmail.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/6c5d6fdd3010 Reset the ObjectElements Frozen flag on OOM. r=ekleog
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla51
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: