<?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>182365</bug_id>
          
          <creation_ts>2018-01-31 16:54:47 -0800</creation_ts>
          <short_desc>[JSCOnly] Ensure RunLoop::Timer is robust to being deleted inside its user callback</short_desc>
          <delta_ts>2018-02-01 06:51:25 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Web Template Framework</component>
          <version>Other</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>INVALID</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=182271</see_also>
          <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="Michael Catanzaro">mcatanzaro</reporter>
          <assigned_to name="Michael Catanzaro">mcatanzaro</assigned_to>
          <cc>benjamin</cc>
    
    <cc>cdumez</cc>
    
    <cc>cmarcelo</cc>
    
    <cc>dbates</cc>
    
    <cc>ews-watchlist</cc>
    
    <cc>mcatanzaro</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1395248</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2018-01-31 16:54:47 -0800</bug_when>
    <thetext>Ensure RunLoop::Timer is robust to being deleted inside its user callback. This is a theoretical issue that I noticed as the result of an actual use-after-free caught by asan in WPE and GTK. See bug #182271. It&apos;s not actually possible to test the original reproducer using JSCOnly, because it was a WebKit-layer problem.

I&apos;m going to attach a totally-untested, speculative fix for the theoretical issue. I think it&apos;s correct.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1395253</commentid>
    <comment_count>1</comment_count>
      <attachid>332825</attachid>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2018-01-31 17:04:48 -0800</bug_when>
    <thetext>Created attachment 332825
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1395255</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2018-01-31 17:08:59 -0800</bug_when>
    <thetext>This should be reviewed by Yusuke, because I&apos;m really not sure whether it&apos;s necessary or not. If the RunLoop itself is guaranteed to have another ref on the ScheduledTask, then this isn&apos;t needed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1395374</commentid>
    <comment_count>3</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2018-02-01 00:27:29 -0800</bug_when>
    <thetext>(In reply to Michael Catanzaro from comment #2)
&gt; This should be reviewed by Yusuke, because I&apos;m really not sure whether it&apos;s
&gt; necessary or not. If the RunLoop itself is guaranteed to have another ref on
&gt; the ScheduledTask, then this isn&apos;t needed.

I don&apos;t think it is necessary. See L173. When calling ScheduledTask::fired(), RunLoop&apos;s code always has ref by `RefPtr&lt;ScheduledTask&gt;`.
BTW, this problem is why I separate ScheduledTask from TimerBase IIRC :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1395443</commentid>
    <comment_count>4</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2018-02-01 06:51:20 -0800</bug_when>
    <thetext>(In reply to Yusuke Suzuki from comment #3)
&gt; I don&apos;t think it is necessary. See L173. When calling
&gt; ScheduledTask::fired(), RunLoop&apos;s code always has ref by
&gt; `RefPtr&lt;ScheduledTask&gt;`.
&gt; BTW, this problem is why I separate ScheduledTask from TimerBase IIRC :)

Good decision ;)</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>332825</attachid>
            <date>2018-01-31 17:04:48 -0800</date>
            <delta_ts>2018-02-01 06:51:25 -0800</delta_ts>
            <desc>Patch</desc>
            <filename>bug-182365-20180131190447.patch</filename>
            <type>text/plain</type>
            <size>1401</size>
            <attacher name="Michael Catanzaro">mcatanzaro</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjI3OTQyCmRpZmYgLS1naXQgYS9Tb3VyY2UvV1RGL0NoYW5n
ZUxvZyBiL1NvdXJjZS9XVEYvQ2hhbmdlTG9nCmluZGV4IDJiNDU0NjU1ODA5NDE5ODQ1M2ZkYzc3
YmE4M2EzOGEwOWE1M2RkOTYuLjlkOTY1MjQ3OTVmMDljZTViYWQ4N2YwZDY5OGY4YWE1YjBkZDBl
MDIgMTAwNjQ0Ci0tLSBhL1NvdXJjZS9XVEYvQ2hhbmdlTG9nCisrKyBiL1NvdXJjZS9XVEYvQ2hh
bmdlTG9nCkBAIC0xLDMgKzEsMTYgQEAKKzIwMTgtMDEtMzEgIE1pY2hhZWwgQ2F0YW56YXJvICA8
bWNhdGFuemFyb0BpZ2FsaWEuY29tPgorCisgICAgICAgIFtKU0NPbmx5XSBFbnN1cmUgUnVuTG9v
cDo6VGltZXIgaXMgcm9idXN0IHRvIGJlaW5nIGRlbGV0ZWQgaW5zaWRlIGl0cyB1c2VyIGNhbGxi
YWNrCisgICAgICAgIGh0dHBzOi8vYnVncy53ZWJraXQub3JnL3Nob3dfYnVnLmNnaT9pZD0xODIz
NjUKKworICAgICAgICBSZXZpZXdlZCBieSBOT0JPRFkgKE9PUFMhKS4KKworICAgICAgICBUaGlz
IGlzIGEgc3BlY3VsYXRpdmUgZml4IGZvciBhIHRoZW9yZXRpY2FsIGlzc3VlLiBFbnN1cmUgdGhl
IFNjaGVkdWxlZFRhc2sgZG9lcyBub3QgYWxsb3cKKyAgICAgIC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flag name="review"
          id="351742"
          type_id="1"
          status="-"
          setter="mcatanzaro"
    />
          </attachment>
      

    </bug>

</bugzilla>