<?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>221548</bug_id>
          
          <creation_ts>2021-02-08 05:55:34 -0800</creation_ts>
          <short_desc>comment blocks cause incorrect reporting of column numbers in stack traces</short_desc>
          <delta_ts>2022-03-24 21:15:46 -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>Safari 14</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</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>dan</reporter>
          <assigned_to name="Yusuke Suzuki">ysuzuki</assigned_to>
          <cc>ashvayka</cc>
    
    <cc>aswan</cc>
    
    <cc>fpizlo</cc>
    
    <cc>jond</cc>
    
    <cc>keith_miller</cc>
    
    <cc>saam</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1726614</commentid>
    <comment_count>0</comment_count>
    <who name="">dan</who>
    <bug_when>2021-02-08 05:55:34 -0800</bug_when>
    <thetext>Consider this JavaScript executing on a webpage, imported as an external script file:

window.onload = () =&gt; {
  console.log(&apos;something unrelated&apos;);const e = new Error(&quot;new error&quot;);console.log(e.stack);console.log(&apos;something unrelated&apos;);
}

The output of `console.log(e.stack)` in the Safari console is: http://127.0.0.1:8081/build/main.js:2:57

Note the column number. 57 is between the &quot;r&quot; and the &quot;(&quot; in new Error(&quot;new error&quot;). This looks good.

Now consider this:

window.onload = () =&gt; {/*
  something about this comment means the line number gets reported incorrectly in the stack
  */console.log(&apos;something unrelated&apos;);const e = new Error(&quot;new error&quot;);console.log(e.stack);console.log(&apos;something unrelated&apos;);
}

The relevant output is then: http://127.0.0.1:8081/build/main.js:3:161

Now the stack trace is reporting the error occurred at column 161, which does not exist.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1729142</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2021-02-15 05:56:12 -0800</bug_when>
    <thetext>&lt;rdar://problem/74347565&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1852592</commentid>
    <comment_count>2</comment_count>
    <who name="Andrew Swan">aswan</who>
    <bug_when>2022-03-17 19:00:05 -0700</bug_when>
    <thetext>In addition to the original report, this also happens with multi-line strings:

window.onload = () =&gt; {
    let s = `
multi
line
string
`;console.log(&apos;something unrelated&apos;);const e = new Error(&quot;new error&quot;);console.log(e.stack);console.log(&apos;something unrelated&apos;);
}

This is creating problems for us as we use source maps to translate the locations of javascript errors, but the incorrect column numbers are causing this translation to break.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1852593</commentid>
    <comment_count>3</comment_count>
    <who name="Andrew Swan">aswan</who>
    <bug_when>2022-03-17 19:03:06 -0700</bug_when>
    <thetext>And fwiw, I think https://bugs.webkit.org/show_bug.cgi?id=213873 is probably due to the same underlying issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1854956</commentid>
    <comment_count>4</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2022-03-24 17:28:35 -0700</bug_when>
    <thetext>Thanks! This is fixed in bug 235607 :)
Let us add some more test cases to ensure this.

*** This bug has been marked as a duplicate of bug 235607 ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1854965</commentid>
    <comment_count>5</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2022-03-24 17:38:42 -0700</bug_when>
    <thetext>Reopening to attach new patch.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1854966</commentid>
    <comment_count>6</comment_count>
      <attachid>455712</attachid>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2022-03-24 17:38:44 -0700</bug_when>
    <thetext>Created attachment 455712
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1855001</commentid>
    <comment_count>7</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2022-03-24 21:15:42 -0700</bug_when>
    <thetext>Committed r291847 (248859@main): &lt;https://commits.webkit.org/248859@main&gt;

All reviewed patches have been landed. Closing bug and clearing flags on attachment 455712.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>455712</attachid>
            <date>2022-03-24 17:38:44 -0700</date>
            <delta_ts>2022-03-24 21:15:43 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-221548-20220324173843.patch</filename>
            <type>text/plain</type>
            <size>1798</size>
            <attacher name="Yusuke Suzuki">ysuzuki</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjkxODM3CmRpZmYgLS1naXQgYS9KU1Rlc3RzL0NoYW5nZUxv
ZyBiL0pTVGVzdHMvQ2hhbmdlTG9nCmluZGV4IGEyZTViZWU1YWE3OTRmYjA4ZjE1ODcxM2QxZGI0
MGM0NDgyNWIwZTAuLjQ5ZTBkNjEyNTY1YzBjZWUyYjYxN2MzN2Y2NzE0ZjU2YzZiMGQ0N2IgMTAw
NjQ0Ci0tLSBhL0pTVGVzdHMvQ2hhbmdlTG9nCisrKyBiL0pTVGVzdHMvQ2hhbmdlTG9nCkBAIC0x
LDMgKzEsMTcgQEAKKzIwMjItMDMtMjQgIFl1c3VrZSBTdXp1a2kgIDx5c3V6dWtpQGFwc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DAwMDAwMDAw
MDAwLi41ODg3YzE5OTRhNTIzMTAxMTc5ZGIwNmYyNGRmYTdmZWI2MmI1NDQzCi0tLSAvZGV2L251
bGwKKysrIGIvSlNUZXN0cy9zdHJlc3MvbXVsdGlsaW5lLXRva2VuLWVycm9yLWNvbHVtbi5qcwpA
QCAtMCwwICsxLDI0IEBACitmdW5jdGlvbiBzaG91bGRCZShhY3R1YWwsIGV4cGVjdGVkKSB7Cisg
ICAgaWYgKGFjdHVhbCAhPT0gZXhwZWN0ZWQpCisgICAgICAgIHRocm93IG5ldyBFcnJvcignYmFk
IHZhbHVlOiAnICsgYWN0dWFsKTsKK30KKworeworICAgIGxldCB7IGxpbmUsIGNvbHVtbiB9ID0g
KGZ1bmN0aW9uKCkgey8qCisgICAgICBzb21ldGhpbmcgYWJvdXQgdGhpcyBjb21tZW50IG1lYW5z
IHRoZSBsaW5lIG51bWJlciBnZXRzIHJlcG9ydGVkIGluY29ycmVjdGx5IGluIHRoZSBzdGFjawor
ICAgICAgKi9jb25zdCBlID0gbmV3IEVycm9yKCJuZXcgZXJyb3IiKTsgcmV0dXJuIGU7CisgICAg
fSkoKTsKKyAgICBzaG91bGRCZShsaW5lLCA5KTsKKyAgICBzaG91bGRCZShjb2x1bW4sIDI4KTsK
K30KK3sKKyAgICBsZXQgeyBsaW5lLCBjb2x1bW4gfSA9IChmdW5jdGlvbigpIHsKKyAgICAgICAg
bGV0IHMgPSBgCittdWx0aQorbGluZQorc3RyaW5nCitgOyBjb25zdCBlID0gbmV3IEVycm9yKCJu
ZXcgZXJyb3IiKTsgcmV0dXJuIGU7CisgICAgfSkoKTsKKyAgICBzaG91bGRCZShsaW5lLCAyMCk7
CisgICAgc2hvdWxkQmUoY29sdW1uLCAyMyk7Cit9Cg==
</data>

          </attachment>
      

    </bug>

</bugzilla>