<?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>190449</bug_id>
          
          <creation_ts>2018-10-10 15:22:22 -0700</creation_ts>
          <short_desc>makeWeakPtr() on a derived class provides a bad pointer if CanMakeWeakPtr&lt;&gt; is not its first base class</short_desc>
          <delta_ts>2018-10-11 11:13:28 -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>NEW</bug_status>
          <resolution></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="Simon Fraser (smfr)">simon.fraser</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>cdumez</cc>
    
    <cc>ggaren</cc>
    
    <cc>jiewen_tan</cc>
    
    <cc>koivisto</cc>
    
    <cc>lforschler</cc>
    
    <cc>sam</cc>
    
    <cc>simon.fraser</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1467853</commentid>
    <comment_count>0</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2018-10-10 15:22:22 -0700</bug_when>
    <thetext>I changed RenderLayer to:

class RenderLayer final : public RenderLayerNode, public ScrollableArea {
...
}

where RenderLayerNode is a base class with virtual members
and ScrollableArea is:

class ScrollableArea : public CanMakeWeakPtr&lt;ScrollableArea&gt; {
...
}

This triggered crashes in code that referenced weak ptrs to RenderLayers. It seems that weak_reference_downcast() assumes that the pointers are reinterpret-castable, but that&apos;s not always true.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1467940</commentid>
    <comment_count>1</comment_count>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2018-10-10 20:17:25 -0700</bug_when>
    <thetext>Related:

https://bugs.webkit.org/show_bug.cgi?id=188799
https://bugs.webkit.org/show_bug.cgi?id=179405</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1467949</commentid>
    <comment_count>2</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2018-10-10 20:44:50 -0700</bug_when>
    <thetext>This could probably be marked a dup of one of those. I&apos;d like this to work soonish...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1467951</commentid>
    <comment_count>3</comment_count>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2018-10-10 20:59:17 -0700</bug_when>
    <thetext>A short-term workaround is to list ScrollableArea first in the inheritance hierarchy:

class RenderLayer final : public ScrollableArea, public RenderLayerNode {</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1468057</commentid>
    <comment_count>4</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2018-10-11 09:39:53 -0700</bug_when>
    <thetext>Sadly that breaks some other casting I wanted to do (but may have to do differently).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1468088</commentid>
    <comment_count>5</comment_count>
    <who name="Antti Koivisto">koivisto</who>
    <bug_when>2018-10-11 11:13:28 -0700</bug_when>
    <thetext>I&apos;ll try to fix WeakPtr at some point.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>