Closed
Bug 1125624
Opened 10 years ago
Closed 10 years ago
Merge DefineProperty with StandardDefineProperty
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
mozilla41
Tracking | Status | |
---|---|---|
firefox-esr38 | - | --- |
People
(Reporter: evilpies, Assigned: jorendorff)
References
(Blocks 2 open bugs)
Details
Attachments
(3 files, 1 obsolete file)
6.87 KB,
patch
|
Waldo
:
review+
|
Details | Diff | Splinter Review |
17.38 KB,
patch
|
Waldo
:
review+
|
Details | Diff | Splinter Review |
18.31 KB,
patch
|
Waldo
:
review+
|
Details | Diff | Splinter Review |
Everything else might be slightly wrong. Also not the ProperyDescriptor overload, but PropDesc version.
Assignee | ||
Comment 1•10 years ago
|
||
I'm taking over this bug. The answer is to only have one thing rather than two things.
Summary: Use StandardDefineProperty everywhere → Merge DefineProperty with StandardDefineProperty and PropDesc with PropertyDescriptor
Assignee | ||
Updated•10 years ago
|
Blocks: CVE-2015-4516
Assignee | ||
Updated•10 years ago
|
Blocks: es6internalmethods
Assignee | ||
Updated•10 years ago
|
Summary: Merge DefineProperty with StandardDefineProperty and PropDesc with PropertyDescriptor → Merge DefineProperty with StandardDefineProperty
Updated•10 years ago
|
Blocks: CVE-2015-4478
Updated•10 years ago
|
No longer blocks: CVE-2015-4478
Assignee | ||
Comment 3•10 years ago
|
||
Assignee | ||
Comment 4•10 years ago
|
||
Assignee | ||
Comment 5•10 years ago
|
||
Assignee | ||
Comment 6•10 years ago
|
||
Assignee | ||
Comment 7•10 years ago
|
||
Assignee | ||
Comment 8•10 years ago
|
||
Assignee | ||
Comment 9•10 years ago
|
||
Calling the hook is bad because sometimes the object is an XPConnect object with an addProperty hook that always throws.
This patch contains two hacks I'm unsure about, both related to the same situation: NativeDefineProperty is called from JSOP_INITPROP after JSOP_NEWOBJECT.
1. In GetExistingPropertyValue, avoid calling GetExistingProperty in a case where that would trigger an assertion. An alternative might be to weaken the assertion so that it is effectively skipped if obj's group has Addendum_PreliminaryObjects.
2. In NativeDefineProperty, when redundant is true, we update the type even though neither the shape nor the value is changing! Without this hack, we get assertion failures in Ion later.
Attachment #8613185 -
Flags: review?(jwalden+bmo)
Assignee | ||
Updated•10 years ago
|
Assignee: nobody → jorendorff
Status: NEW → ASSIGNED
Assignee | ||
Comment 10•10 years ago
|
||
Attachment #8613187 -
Flags: review?(jwalden+bmo)
Assignee | ||
Comment 11•10 years ago
|
||
Attachment #8613188 -
Flags: review?(jwalden+bmo)
Assignee | ||
Comment 12•10 years ago
|
||
Comment on attachment 8613185 [details] [diff] [review]
part 1 - Implement ValidateAndApplyPropertyDescriptor steps 3-4, so that (once the corresponding code in StandardDefineProperty is deleted) freezing an already-frozen object with an addProperty class hook will not call the hook
Review of attachment 8613185 [details] [diff] [review]:
-----------------------------------------------------------------
Adding r?bhackett specifically for the "two hacks I'm unsure about" (see last 3 paragraphs of comment 9).
Attachment #8613185 -
Flags: review?(bhackett1024)
Comment 13•10 years ago
|
||
Comment on attachment 8613185 [details] [diff] [review]
part 1 - Implement ValidateAndApplyPropertyDescriptor steps 3-4, so that (once the corresponding code in StandardDefineProperty is deleted) freezing an already-frozen object with an addProperty class hook will not call the hook
Review of attachment 8613185 [details] [diff] [review]:
-----------------------------------------------------------------
::: js/src/vm/NativeObject.cpp
@@ +1212,5 @@
> + // Avoid failing a too-strict assertion in GetExistingProperty.
> + if (shape->hasSlot() && shape->hasDefaultGetter()) {
> + vp.set(obj->getSlot(shape->slot()));
> + return true;
> + }
I think this is effectively neutering that early assertion in GetExistingProperty. What are the circumstances under which the assert is failing? Addendum_PreliminaryObjects shouldn't be involved here (it just indicates the object is one of the first ones created with the given group).
In JSOP_NEWOBJECT objects the new objects are created with an initial set of properties which have undefined values. Those initial undefined values are not accounted for by TI, which is I guess why the assert is failing. Script will never be able to observe the values of these properties before they are assigned to, so we allow this, but it sounds like the assertion should be weakened for some calling context where the VM reads the value of the property when it is first assigned to?
@@ +1376,5 @@
> + if (!IsImplicitDenseOrTypedArrayElement(shape) && desc.hasValue()) {
> + if (!UpdateShapeTypeAndValue(cx, obj, shape, desc.value()))
> + return false;
> + }
> + return result.succeed();
I would guess this is probably also involved with the issue described above. If the INITPROP is initializing a property with |undefined| then because of the initial properties on the NEWOBJECT object the DefineProperty will seem to be redundant, but the types on the ObjectGroup have not been updated to reflect that undefined value, so this should indeed update type information. Do you see this happening with any values other than |undefined|?
Attachment #8613185 -
Flags: review?(bhackett1024)
Assignee | ||
Comment 14•10 years ago
|
||
Attachment #8613582 -
Flags: review?(jwalden+bmo)
Assignee | ||
Updated•10 years ago
|
Attachment #8613188 -
Attachment is obsolete: true
Attachment #8613188 -
Flags: review?(jwalden+bmo)
Assignee | ||
Comment 15•10 years ago
|
||
(In reply to Brian Hackett (:bhackett) from comment #13)
> What are the circumstances under which the assert is
> failing?
This happens under JSOP_INITPROP, targeting an object created by JSOP_NEWOBJECT.
JSOP_INITPROP calls js::NativeDefineProperty. This patch makes that call DefinePropertyIsRedundant, which calls GetExistingPropertyValue, which triggers the assertion.
(I would rather not be doing any of this. Unfortunately, DefinePropertyIsRedundant is not just a particularly dumb optimization. See the first 2 paragraphs of comment 9. :-P)
> Addendum_PreliminaryObjects shouldn't be involved here (it just
> indicates the object is one of the first ones created with the given group).
OK, then it just happens to be set because when we fail the assertion, it's the first time through. Red herring, sorry.
> it sounds like the assertion should be
> weakened for some calling context where the VM reads the value of the
> property when it is first assigned to?
Right. That's sort of what I'm trying to do here ... I don't see a better way to do it by e.g. adding a condition to the MOZ_ASSERT_IF.
...Maybe I could make the JSOP_NEWOBJECT machinery initialize the fields to a magic value rather than undefined, and skip the assertion when the slot contains that magic value. (?)
> Do you see this happening with any values other than |undefined|?
No. I agree with everything you wrote, and I think it only happens in the exact case you're describing.
Assignee | ||
Updated•10 years ago
|
Flags: needinfo?(bhackett1024)
Comment 16•10 years ago
|
||
(In reply to Jason Orendorff [:jorendorff] from comment #15)
> (In reply to Brian Hackett (:bhackett) from comment #13)
> > What are the circumstances under which the assert is
> > failing?
>
> This happens under JSOP_INITPROP, targeting an object created by
> JSOP_NEWOBJECT.
>
> JSOP_INITPROP calls js::NativeDefineProperty. This patch makes that call
> DefinePropertyIsRedundant, which calls GetExistingPropertyValue, which
> triggers the assertion.
>
> (I would rather not be doing any of this. Unfortunately,
> DefinePropertyIsRedundant is not just a particularly dumb optimization. See
> the first 2 paragraphs of comment 9. :-P)
OK, how about adding the '// Avoid failing a too-strict assertion ...' block or similar code to DefinePropertyIsRedundant itself, to run as an alternative to GetExistingPropertyValue if possible. Then other callers to GetExistingPropertyValue will benefit from the assertion, and the assertion itself won't need to be changed.
Flags: needinfo?(bhackett1024)
Assignee | ||
Comment 17•10 years ago
|
||
OK, I'll do that. And improve the comment.
Comment 18•10 years ago
|
||
Comment on attachment 8613185 [details] [diff] [review]
part 1 - Implement ValidateAndApplyPropertyDescriptor steps 3-4, so that (once the corresponding code in StandardDefineProperty is deleted) freezing an already-frozen object with an addProperty class hook will not call the hook
Review of attachment 8613185 [details] [diff] [review]:
-----------------------------------------------------------------
I kinda like the MagicValue(JS_UNINITIALIZED_OBJECT_PROPERTY) idea, maybe slightly more than the alternative thing. Seems like an uninitialized property sentinel could have more value than in just this one weird assertion case. But comment 16 is also okay enough.
::: js/src/vm/NativeObject.cpp
@@ +1233,5 @@
> + if (desc.hasConfigurable() && desc.configurable() != ((shapeAttrs & JSPROP_PERMANENT) == 0))
> + return true;
> + if (desc.hasEnumerable() && desc.enumerable() != ((shapeAttrs & JSPROP_ENUMERATE) != 0))
> + return true;
> + if (desc.hasWritable() || desc.hasValue()) {
Wasn't there an isDataDescriptor() method to abbreviate this?
@@ +1246,5 @@
> +
> + // The specification calls for SameValue here, but it seems to be a
> + // bug. See <https://bugs.ecmascript.org/show_bug.cgi?id=3508>.
> + if (desc.value() != currentValue)
> + return true;
Bah. Stab typed arrays repeatedly.
Attachment #8613185 -
Flags: review?(jwalden+bmo) → review+
Assignee | ||
Comment 19•10 years ago
|
||
Assignee | ||
Comment 20•10 years ago
|
||
Assignee | ||
Comment 21•10 years ago
|
||
Updated•10 years ago
|
Attachment #8613187 -
Flags: review?(jwalden+bmo) → review+
Updated•10 years ago
|
Attachment #8613582 -
Flags: review?(jwalden+bmo) → review+
Assignee | ||
Comment 24•10 years ago
|
||
Comment 25•10 years ago
|
||
Comment 26•10 years ago
|
||
sorry had to back this out in https://treeherder.mozilla.org/#/jobs?repo=mozilla-inbound&revision=65e6e21a4725 i think that something in this push caused test failures like https://treeherder.mozilla.org/logviewer.html#?job_id=10872015&repo=mozilla-inbound
Assignee | ||
Comment 27•10 years ago
|
||
Comment 28•10 years ago
|
||
Assignee | ||
Updated•10 years ago
|
Updated•10 years ago
|
Target Milestone: --- → mozilla41
Comment 29•9 years ago
|
||
Jason, do you want to request uplift for this to esr ? It could still make it into esr 38.3.0.
Flags: needinfo?(jorendorff)
Updated•9 years ago
|
tracking-firefox-esr38:
--- → ?
Comment 32•9 years ago
|
||
OK, thanks
You need to log in
before you can comment on or make changes to this bug.
Description
•