<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>120314</bug_id>
          
          <creation_ts>2013-08-26 10:03:46 -0700</creation_ts>
          <short_desc>Object.defineProperty should be able to create a PropertyDescriptor where m_attributes == 0</short_desc>
          <delta_ts>2013-08-26 14:11:03 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>JavaScriptCore</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Mark Hahnenberg">mhahnenberg</reporter>
          <assigned_to name="Mark Hahnenberg">mhahnenberg</assigned_to>
          <cc>darin</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>921052</commentid>
    <comment_count>0</comment_count>
    <who name="Mark Hahnenberg">mhahnenberg</who>
    <bug_when>2013-08-26 10:03:46 -0700</bug_when>
    <thetext>Currently with the way that defineProperty works, we leave a stray low bit set in PropertyDescriptor::m_attributes in the following code:

var o = {};
Object.defineProperty(o, 100, {writable:true, enumerable:true, configurable:true, value:&quot;foo&quot;});

This is due to the fact that the lowest non-zero attribute (ReadOnly) is represented as 1 &lt;&lt; 1 instead of 1 &lt;&lt; 0. We then calculate the default attributes as ((1 &lt;&lt; 3) &lt;&lt; 1) - 1, which is 0xF, but only the top three bits mean anything. Even in the case above, the top three bits are set to 0 but the bottom bit remains set, which causes us to think m_attributes is non-zero.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>921057</commentid>
    <comment_count>1</comment_count>
      <attachid>209660</attachid>
    <who name="Mark Hahnenberg">mhahnenberg</who>
    <bug_when>2013-08-26 10:09:43 -0700</bug_when>
    <thetext>Created attachment 209660
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>921061</commentid>
    <comment_count>2</comment_count>
      <attachid>209660</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2013-08-26 10:14:27 -0700</bug_when>
    <thetext>Comment on attachment 209660
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=209660&amp;action=review

&gt; Source/JavaScriptCore/ChangeLog:17
&gt; +        This is due to the fact that the lowest non-zero attribute (ReadOnly) is represented as 1 &lt;&lt; 1 
&gt; +        instead of 1 &lt;&lt; 0. We then calculate the default attributes as ((1 &lt;&lt; 3) &lt;&lt; 1) - 1, which is 0xF, 
&gt; +        but only the top three bits mean anything. Even in the case above, the top three bits are set 
&gt; +        to 0 but the bottom bit remains set, which causes us to think m_attributes is non-zero.

I think the real problem is in the code that calculates the default attributes. Where is that code? Is there some reason it has to do &quot;((1 &lt;&lt; 3) &lt;&lt; 1) - 1&quot; instead of just or&apos;ing together the specific attributes?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>921064</commentid>
    <comment_count>3</comment_count>
    <who name="Mark Hahnenberg">mhahnenberg</who>
    <bug_when>2013-08-26 10:20:17 -0700</bug_when>
    <thetext>(In reply to comment #2)
&gt; (From update of attachment 209660 [details])
&gt; View in context: https://bugs.webkit.org/attachment.cgi?id=209660&amp;action=review
&gt; 
&gt; &gt; Source/JavaScriptCore/ChangeLog:17
&gt; &gt; +        This is due to the fact that the lowest non-zero attribute (ReadOnly) is represented as 1 &lt;&lt; 1 
&gt; &gt; +        instead of 1 &lt;&lt; 0. We then calculate the default attributes as ((1 &lt;&lt; 3) &lt;&lt; 1) - 1, which is 0xF, 
&gt; &gt; +        but only the top three bits mean anything. Even in the case above, the top three bits are set 
&gt; &gt; +        to 0 but the bottom bit remains set, which causes us to think m_attributes is non-zero.
&gt; 
&gt; I think the real problem is in the code that calculates the default attributes. Where is that code? Is there some reason it has to do &quot;((1 &lt;&lt; 3) &lt;&lt; 1) - 1&quot; instead of just or&apos;ing together the specific attributes?

It&apos;s in PropertyDescriptor.cpp:

unsigned PropertyDescriptor::defaultAttributes = (DontDelete &lt;&lt; 1) - 1;

I agree that it would be better style to or the default attributes together. I&apos;ll make that change.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>921075</commentid>
    <comment_count>4</comment_count>
    <who name="Mark Hahnenberg">mhahnenberg</who>
    <bug_when>2013-08-26 10:33:09 -0700</bug_when>
    <thetext>(In reply to comment #2)
&gt; (From update of attachment 209660 [details])
&gt; View in context: https://bugs.webkit.org/attachment.cgi?id=209660&amp;action=review
&gt; 
&gt; &gt; Source/JavaScriptCore/ChangeLog:17
&gt; &gt; +        This is due to the fact that the lowest non-zero attribute (ReadOnly) is represented as 1 &lt;&lt; 1 
&gt; &gt; +        instead of 1 &lt;&lt; 0. We then calculate the default attributes as ((1 &lt;&lt; 3) &lt;&lt; 1) - 1, which is 0xF, 
&gt; &gt; +        but only the top three bits mean anything. Even in the case above, the top three bits are set 
&gt; &gt; +        to 0 but the bottom bit remains set, which causes us to think m_attributes is non-zero.
&gt; 
&gt; I think the real problem is in the code that calculates the default attributes. Where is that code? Is there some reason it has to do &quot;((1 &lt;&lt; 3) &lt;&lt; 1) - 1&quot; instead of just or&apos;ing together the specific attributes?

Hmm, a couple of these constants are exposed as part of the JavaScriptCore framework&apos;s C API in JSObjectRef.h (e.g. kJSPropertyAttributeReadOnly).  Perhaps it would be better to just change how the default attributes are calculated internally and leave the other values alone.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>921132</commentid>
    <comment_count>5</comment_count>
    <who name="Mark Hahnenberg">mhahnenberg</who>
    <bug_when>2013-08-26 13:00:52 -0700</bug_when>
    <thetext>Committed r154630: &lt;http://trac.webkit.org/changeset/154630&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>921156</commentid>
    <comment_count>6</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2013-08-26 14:11:03 -0700</bug_when>
    <thetext>(In reply to comment #4)
&gt; Hmm, a couple of these constants are exposed as part of the JavaScriptCore framework&apos;s C API in JSObjectRef.h (e.g. kJSPropertyAttributeReadOnly).

Please add a COMPILE_ASSERT to keep these in sync.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>209660</attachid>
            <date>2013-08-26 10:09:43 -0700</date>
            <delta_ts>2013-08-26 10:14:27 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-120314-20130826100943.patch</filename>
            <type>text/plain</type>
            <size>2482</size>
            <attacher name="Mark Hahnenberg">mhahnenberg</attacher>
            
              <data encoding="base64">SW5kZXg6IFNvdXJjZS9KYXZhU2NyaXB0Q29yZS9DaGFuZ2VMb2cKPT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQotLS0gU291
cmNlL0phdmFTY3JpcHRDb3JlL0NoYW5nZUxvZwkocmV2aXNpb24gMTU0NjA5KQorKysgU291cmNl
L0phdmFTY3JpcHRDb3JlL0NoYW5nZUxvZwkod29ya2luZyBjb3B5KQpAQCAtMSwzICsxLDIzIEBA
CisyMDEzLTA4LTI2ICBNYXJrIEhhaG5lbmJlcmcgIDxtaGFobmVuYmVyZ0BhcHBsZS5jb20+CisK
KyAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5IHNob3VsZCBiZSBhYmxlIHRvIGNyZWF0ZSBh
IFByb3BlcnR5RGVzY3JpcHRvciB3aGVyZSBtX2F0dHJpYnV0ZXMgPT0gMAorICAgICAgICBodHRw
czovL2J1Z3Mud2Via2l0Lm9yZy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F0aWMgaGFzaHRhYmxlcwotICAg
IEFjY2Vzc29yICAgICA9IDEgPDwgNSwgIC8vIHByb3BlcnR5IGlzIGEgZ2V0dGVyL3NldHRlcgor
ICAgIFJlYWRPbmx5ICAgICA9IDEgPDwgMCwgLy8gcHJvcGVydHkgY2FuIGJlIG9ubHkgcmVhZCwg
bm90IHdyaXR0ZW4KKyAgICBEb250RW51bSAgICAgPSAxIDw8IDEsIC8vIHByb3BlcnR5IGRvZXNu
J3QgYXBwZWFyIGluIChmb3IgLi4gaW4gLi4pCisgICAgRG9udERlbGV0ZSAgID0gMSA8PCAyLCAv
LyBwcm9wZXJ0eSBjYW4ndCBiZSBkZWxldGVkCisgICAgRnVuY3Rpb24gICAgID0gMSA8PCAzLCAv
LyBwcm9wZXJ0eSBpcyBhIGZ1bmN0aW9uIC0gb25seSB1c2VkIGJ5IHN0YXRpYyBoYXNodGFibGVz
CisgICAgQWNjZXNzb3IgICAgID0gMSA8PCA0LCAvLyBwcm9wZXJ0eSBpcyBhIGdldHRlci9zZXR0
ZXIKIH07CiAKIGNsYXNzIFByb3BlcnR5U2xvdCB7Cg==
</data>
<flag name="review"
          id="231706"
          type_id="1"
          status="+"
          setter="darin"
    />
          </attachment>
      

    </bug>

</bugzilla>