<?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>198096</bug_id>
          
          <creation_ts>2019-05-21 17:10:43 -0700</creation_ts>
          <short_desc>WHLSL: Parsing negative int literals parses the positive value instead</short_desc>
          <delta_ts>2019-05-21 20:06:18 -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>WebGPU</component>
          <version>WebKit 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>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Saam Barati">saam</reporter>
          <assigned_to name="Saam Barati">saam</assigned_to>
          <cc>commit-queue</cc>
    
    <cc>dino</cc>
    
    <cc>fpizlo</cc>
    
    <cc>jonlee</cc>
    
    <cc>justin_fan</cc>
    
    <cc>mmaxfield</cc>
    
    <cc>rmorisset</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1538061</commentid>
    <comment_count>0</comment_count>
    <who name="Saam Barati">saam</who>
    <bug_when>2019-05-21 17:10:43 -0700</bug_when>
    <thetext>...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1538079</commentid>
    <comment_count>1</comment_count>
      <attachid>370365</attachid>
    <who name="Saam Barati">saam</who>
    <bug_when>2019-05-21 18:25:18 -0700</bug_when>
    <thetext>Created attachment 370365
patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1538080</commentid>
    <comment_count>2</comment_count>
      <attachid>370365</attachid>
    <who name="Myles C. Maxfield">mmaxfield</who>
    <bug_when>2019-05-21 18:32:21 -0700</bug_when>
    <thetext>Comment on attachment 370365
patch

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

&gt; Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.cpp:233
&gt; +        int64_t intResult = -static_cast&lt;int64_t&gt;(result);

Don&apos;t we still need a static assert, though? C++ doesn&apos;t guarantee int64_t is wider than int.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1538082</commentid>
    <comment_count>3</comment_count>
      <attachid>370365</attachid>
    <who name="Saam Barati">saam</who>
    <bug_when>2019-05-21 18:35:49 -0700</bug_when>
    <thetext>Comment on attachment 370365
patch

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

&gt;&gt; Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.cpp:233
&gt;&gt; +        int64_t intResult = -static_cast&lt;int64_t&gt;(result);
&gt; 
&gt; Don&apos;t we still need a static assert, though? C++ doesn&apos;t guarantee int64_t is wider than int.

Few reasons I removed it:
1. This is not the only place relying on sizeof(int) == 4. All of WK relies on this. It&apos;s not super helpful to just have it here.
2. We could also take this further. I don&apos;t believe sizeof(unsigned) is guaranteed to be 4. So let&apos;s say sizeof(unsigned) == 8, then the static_cast from unsigned to int64_t is also broken. I could add another static_assert, but the same as above: lots of things in WK would be broken if sizeof(unsigned) != 4</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1538083</commentid>
    <comment_count>4</comment_count>
    <who name="Saam Barati">saam</who>
    <bug_when>2019-05-21 18:36:40 -0700</bug_when>
    <thetext>(In reply to Saam Barati from comment #3)
&gt; Comment on attachment 370365 [details]
&gt; patch
&gt; 
&gt; View in context:
&gt; https://bugs.webkit.org/attachment.cgi?id=370365&amp;action=review
&gt; 
&gt; &gt;&gt; Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.cpp:233
&gt; &gt;&gt; +        int64_t intResult = -static_cast&lt;int64_t&gt;(result);
&gt; &gt; 
&gt; &gt; Don&apos;t we still need a static assert, though? C++ doesn&apos;t guarantee int64_t is wider than int.
&gt; 
&gt; Few reasons I removed it:
&gt; 1. This is not the only place relying on sizeof(int) == 4. All of WK relies
&gt; on this. It&apos;s not super helpful to just have it here.
&gt; 2. We could also take this further. I don&apos;t believe sizeof(unsigned) is
&gt; guaranteed to be 4. So let&apos;s say sizeof(unsigned) == 8, then the static_cast
&gt; from unsigned to int64_t is also broken. I could add another static_assert,
&gt; but the same as above: lots of things in WK would be broken if
&gt; sizeof(unsigned) != 4

The nicer thing could be to switch to uint32_t/int32_t/int64_t everywhere.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1538088</commentid>
    <comment_count>5</comment_count>
    <who name="Myles C. Maxfield">mmaxfield</who>
    <bug_when>2019-05-21 18:48:53 -0700</bug_when>
    <thetext>&gt; &gt; Few reasons I removed it:
&gt; &gt; 1. This is not the only place relying on sizeof(int) == 4. All of WK relies
&gt; &gt; on this.
Don&apos;t we want this code to be easily separable from WebKit?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1538089</commentid>
    <comment_count>6</comment_count>
    <who name="Saam Barati">saam</who>
    <bug_when>2019-05-21 18:58:16 -0700</bug_when>
    <thetext>(In reply to Myles C. Maxfield from comment #5)
&gt; &gt; &gt; Few reasons I removed it:
&gt; &gt; &gt; 1. This is not the only place relying on sizeof(int) == 4. All of WK relies
&gt; &gt; &gt; on this.
&gt; Don&apos;t we want this code to be easily separable from WebKit?

Not sure. I’ll defer to you on that. 

Anyways, this isn’t a super interesting thing to worry about. It sounds like we should use int32_t since that is probably what’s specified by WHLSL. (And also use uint32_t/int64_t, etc, in surrounding code.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1538096</commentid>
    <comment_count>7</comment_count>
    <who name="Saam Barati">saam</who>
    <bug_when>2019-05-21 19:17:58 -0700</bug_when>
    <thetext>(In reply to Saam Barati from comment #6)
&gt; (In reply to Myles C. Maxfield from comment #5)
&gt; &gt; &gt; &gt; Few reasons I removed it:
&gt; &gt; &gt; &gt; 1. This is not the only place relying on sizeof(int) == 4. All of WK relies
&gt; &gt; &gt; &gt; on this.
&gt; &gt; Don&apos;t we want this code to be easily separable from WebKit?
&gt; 
&gt; Not sure. I’ll defer to you on that. 
&gt; 
&gt; Anyways, this isn’t a super interesting thing to worry about. It sounds like
&gt; we should use int32_t since that is probably what’s specified by WHLSL. (And
&gt; also use uint32_t/int64_t, etc, in surrounding code.)

This is somewhat annoying to do. I&apos;ll just add back a similar static_assert. Anyways, we should consider using types that specify width in the areas that&apos;s specified by the specification. This isn&apos;t really that interesting because no one is going to compile C programs with sizeof(int)/sizeof(unsigned) not equal to 4.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1538097</commentid>
    <comment_count>8</comment_count>
      <attachid>370372</attachid>
    <who name="Saam Barati">saam</who>
    <bug_when>2019-05-21 19:18:32 -0700</bug_when>
    <thetext>Created attachment 370372
patch for landing</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1538105</commentid>
    <comment_count>9</comment_count>
      <attachid>370372</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2019-05-21 20:05:41 -0700</bug_when>
    <thetext>Comment on attachment 370372
patch for landing

Clearing flags on attachment: 370372

Committed r245612: &lt;https://trac.webkit.org/changeset/245612&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1538106</commentid>
    <comment_count>10</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2019-05-21 20:05:43 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1538107</commentid>
    <comment_count>11</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2019-05-21 20:06:18 -0700</bug_when>
    <thetext>&lt;rdar://problem/51012964&gt;</thetext>
  </long_desc>
      
          <attachment
              isobsolete="1"
              ispatch="1"
              isprivate="0"
          >
            <attachid>370365</attachid>
            <date>2019-05-21 18:25:18 -0700</date>
            <delta_ts>2019-05-21 19:18:32 -0700</delta_ts>
            <desc>patch</desc>
            <filename>c-backup.diff</filename>
            <type>text/plain</type>
            <size>2166</size>
            <attacher name="Saam Barati">saam</attacher>
            
              <data encoding="base64">SW5kZXg6IFNvdXJjZS9XZWJDb3JlL0NoYW5nZUxvZwo9PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBTb3VyY2UvV2Vi
Q29yZS9DaGFuZ2VMb2cJKHJldmlzaW9uIDI0NTYwOCkKKysrIFNvdXJjZS9XZWJDb3JlL0NoYW5n
ZUxvZwkod29ya2luZyBjb3B5KQpAQCAtMSwzICsxLDE4IEBACisyMDE5LTA1LTIxICBTYWFtIGJh
cmF0aSAgPHNiYXJhdGlAYXBwbGUuY29tPgorCisgICAgICAgIFdITFNMOiBQYXJzaW5nIG5lZ2F0
aXZlIGludCBsaXRlcmFscyBwYXJzZXMgdGhlIHBvc2l0aXZlIHZhbHVlIGluc3RlYWQKKyAgICAg
ICAgaHR0cHM6Ly9idWdzLndlYmtpdC5vcmcvc2hvd19idWcuY2dpP2lkPTE5ODA5NgorCisgICAg
ICAgIFJldmlld2VkIGJ5IE5PQk9EWSAoT09QUyEpLgorCisgICAgICAgIEkgYWxzbyBtYWRlIHRo
ZSBjb2RlIGFyb3VuZCA8IElOVF9NSU4gYSBiaXQgZWFzaWVyIHRvIGZvbGxvdyBhbG9uZyB3aXRo
LgorCisgICAgICAgIE5vIG5ldyB0ZXN0cyBiZWNhdXNlIHdlIGhhdmVuJ3QgaW1wb3J0ZWQgV0hM
U0wgdGVzdCBzdWl0ZSB5ZXQuCisgICAgICAgIFZlcmlmaWVkIHRoaXMgd29ya3M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SwgImxvbmcgbG9uZyBuZWVkcyB0byBiZSBiaWdnZXIgdGhhbiBhbiBpbnQiKTsKLSAg
ICAgICAgaWYgKHN0YXRpY19jYXN0PGxvbmcgbG9uZz4ocmVzdWx0KSA+IHN0ZDo6YWJzKHN0YXRp
Y19jYXN0PGxvbmcgbG9uZz4oc3RkOjpudW1lcmljX2xpbWl0czxpbnQ+OjptaW4oKSkpKQorICAg
ICAgICBpbnQ2NF90IGludFJlc3VsdCA9IC1zdGF0aWNfY2FzdDxpbnQ2NF90PihyZXN1bHQpOwor
ICAgICAgICBpZiAoaW50UmVzdWx0IDwgc3RhdGljX2Nhc3Q8aW50NjRfdD4oc3RkOjpudW1lcmlj
X2xpbWl0czxpbnQ+OjptaW4oKSkpCiAgICAgICAgICAgICByZXR1cm4gVW5leHBlY3RlZDxQYXJz
ZXI6OkVycm9yPihQYXJzZXI6OkVycm9yKG1ha2VTdHJpbmcoImludCBsaXRlcmFsICIsIHRleHQs
ICIgaXMgb3V0IG9mIGJvdW5kcyIpKSk7Ci0gICAgICAgIHJldHVybiB7IHN0YXRpY19jYXN0PGlu
dD4oc3RhdGljX2Nhc3Q8bG9uZyBsb25nPihyZXN1bHQpICogMSkgfTsKKyAgICAgICAgcmV0dXJu
IHsgc3RhdGljX2Nhc3Q8aW50PihpbnRSZXN1bHQpIH07CiAgICAgfQogICAgIGlmIChyZXN1bHQg
PiBzdGF0aWNfY2FzdDx1bnNpZ25lZD4oc3RkOjpudW1lcmljX2xpbWl0czxpbnQ+OjptYXgoKSkp
CiAgICAgICAgIHJldHVybiBVbmV4cGVjdGVkPFBhcnNlcjo6RXJyb3I+KFBhcnNlcjo6RXJyb3Io
bWFrZVN0cmluZygiaW50IGxpdGVyYWwgIiwgdGV4dCwgIiBpcyBvdXQgb2YgYm91bmRzIikpKTsK
</data>
<flag name="review"
          id="386325"
          type_id="1"
          status="+"
          setter="dino"
    />
          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>370372</attachid>
            <date>2019-05-21 19:18:32 -0700</date>
            <delta_ts>2019-05-21 20:05:41 -0700</delta_ts>
            <desc>patch for landing</desc>
            <filename>c-backup.diff</filename>
            <type>text/plain</type>
            <size>2295</size>
            <attacher name="Saam Barati">saam</attacher>
            
              <data encoding="base64">SW5kZXg6IFNvdXJjZS9XZWJDb3JlL0NoYW5nZUxvZwo9PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBTb3VyY2UvV2Vi
Q29yZS9DaGFuZ2VMb2cJKHJldmlzaW9uIDI0NTYwOCkKKysrIFNvdXJjZS9XZWJDb3JlL0NoYW5n
ZUxvZwkod29ya2luZyBjb3B5KQpAQCAtMSwzICsxLDE4IEBACisyMDE5LTA1LTIxICBTYWFtIGJh
cmF0aSAgPHNiYXJhdGlAYXBwbGUuY29tPgorCisgICAgICAgIFdITFNMOiBQYXJzaW5nIG5lZ2F0
aXZlIGludCBsaXRlcmFscyBwYXJzZXMgdGhlIHBvc2l0aXZlIHZhbHVlIGluc3RlYWQKKyAgICAg
ICAgaHR0cHM6Ly9idWdzLndlYmtpdC5vcmcvc2hvd19idWcuY2dpP2lkPTE5ODA5NgorCisgICAg
ICAgIFJldmlld2VkIGJ5IERlYW4gSmFja3Nvbi4KKworICAgICAgICBJIGFsc28gbWFkZSB0aGUg
Y29kZSBhcm91bmQgPCBJTlRfTUlOIGEgYml0IGVhc2llciB0byBmb2xsb3cgYWxvbmcgd2l0aC4K
KworICAgICAgICBObyBuZXcgdGVzdHMgYmVjYXVzZSB3ZSBoYXZlbid0IGltcG9ydGVkIFdITFNM
IHRlc3Qgc3VpdGUgeWV0LgorICAgICAgICBWZXJpZmllZCB0aGlzIHdvcmtzIHVzaW5nIHRoZSBB
U1QgZHVtcGVyLgorCisgICAgICAgICogTW9kdWxlcy93ZWJncHUvV0hMU0wvV0hMU0xQYXJzZXIu
Y3BwOgorICAgICAgICAoV2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sdCkgPiBzdGQ6OmFicyhzdGF0aWNf
Y2FzdDxsb25nIGxvbmc+KHN0ZDo6bnVtZXJpY19saW1pdHM8aW50Pjo6bWluKCkpKSkKKyAgICAg
ICAgc3RhdGljX2Fzc2VydChzaXplb2YoaW50NjRfdCkgPiBzaXplb2YodW5zaWduZWQpICYmIHNp
emVvZihpbnQ2NF90KSA+IHNpemVvZihpbnQpLCAiVGhpcyBjb2RlIHdvdWxkIGJlIHdyb25nIG90
aGVyd2lzZSIpOworICAgICAgICBpbnQ2NF90IGludFJlc3VsdCA9IC1zdGF0aWNfY2FzdDxpbnQ2
NF90PihyZXN1bHQpOworICAgICAgICBpZiAoaW50UmVzdWx0IDwgc3RhdGljX2Nhc3Q8aW50NjRf
dD4oc3RkOjpudW1lcmljX2xpbWl0czxpbnQ+OjptaW4oKSkpCiAgICAgICAgICAgICByZXR1cm4g
VW5leHBlY3RlZDxQYXJzZXI6OkVycm9yPihQYXJzZXI6OkVycm9yKG1ha2VTdHJpbmcoImludCBs
aXRlcmFsICIsIHRleHQsICIgaXMgb3V0IG9mIGJvdW5kcyIpKSk7Ci0gICAgICAgIHJldHVybiB7
IHN0YXRpY19jYXN0PGludD4oc3RhdGljX2Nhc3Q8bG9uZyBsb25nPihyZXN1bHQpICogMSkgfTsK
KyAgICAgICAgcmV0dXJuIHsgc3RhdGljX2Nhc3Q8aW50PihpbnRSZXN1bHQpIH07CiAgICAgfQog
ICAgIGlmIChyZXN1bHQgPiBzdGF0aWNfY2FzdDx1bnNpZ25lZD4oc3RkOjpudW1lcmljX2xpbWl0
czxpbnQ+OjptYXgoKSkpCiAgICAgICAgIHJldHVybiBVbmV4cGVjdGVkPFBhcnNlcjo6RXJyb3I+
KFBhcnNlcjo6RXJyb3IobWFrZVN0cmluZygiaW50IGxpdGVyYWwgIiwgdGV4dCwgIiBpcyBvdXQg
b2YgYm91bmRzIikpKTsK
</data>

          </attachment>
      

    </bug>

</bugzilla>