<?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>195656</bug_id>
          
          <creation_ts>2019-03-12 17:39:25 -0700</creation_ts>
          <short_desc>Add a thread safety assertion for RefCounted</short_desc>
          <delta_ts>2019-10-23 22:56:54 -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>Web Template Framework</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>200507</dup_id>
          
          <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="Ryosuke Niwa">rniwa</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>achristensen</cc>
    
    <cc>cdumez</cc>
    
    <cc>ddkilzer</cc>
    
    <cc>fujii</cc>
    
    <cc>ggaren</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1515787</commentid>
    <comment_count>0</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2019-03-12 17:39:25 -0700</bug_when>
    <thetext>I think we should add some thread safety check for RefCounted.
Namely, we should avoid creating an object and ref / deref it in two different threads.
Such objects should be using ThreadSafeRefCounted instead.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1515789</commentid>
    <comment_count>1</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2019-03-12 17:40:33 -0700</bug_when>
    <thetext>Note that it&apos;s technically correct to create an object in one thread, pass it to another thread if the new thread has an exclusive ownership / access right. However, such a code is error prone so I&apos;d argue that we shouldn&apos;t have such a code without such code using ThreadSafeRefCounted instead.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1515830</commentid>
    <comment_count>2</comment_count>
    <who name="Fujii Hironori">fujii</who>
    <bug_when>2019-03-12 19:28:17 -0700</bug_when>
    <thetext>WTF::String has a non-atomic ref couter, but it is a quite common pattern to pass a WTF::String cross-threads by using isolatedCopy().</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1515831</commentid>
    <comment_count>3</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2019-03-12 19:31:37 -0700</bug_when>
    <thetext>(In reply to Fujii Hironori from comment #2)
&gt; WTF::String has a non-atomic ref couter, but it is a quite common pattern to
&gt; pass a WTF::String cross-threads by using isolatedCopy().

That&apos;s a good point. Maybe we need to allow this usage in some classes, or perhaps isolatedCopy needs some magic to unset the thread identity.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1516034</commentid>
    <comment_count>4</comment_count>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2019-03-13 10:41:05 -0700</bug_when>
    <thetext>We used to have assertions like this and we had to remove them. The corner case was JavaScriptCore. JavaScriptCore allows clients to run on any thread, and it ensures thread safety through coarse-grained locking. JavaScriptCore also uses many fundamental WTF types. We could not find a practical way to annotate all types as asserting their thread affinity if and only if not used by JavaScriptCore.

But perhaps the opposite is possible: WebCore could annotate certain important objects upon allocation as being tied to a thread.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1583240</commentid>
    <comment_count>5</comment_count>
    <who name="Fujii Hironori">fujii</who>
    <bug_when>2019-10-23 22:56:54 -0700</bug_when>
    <thetext>

*** This bug has been marked as a duplicate of bug 200507 ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>