<?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>233217</bug_id>
          
          <creation_ts>2021-11-16 14:50:10 -0800</creation_ts>
          <short_desc>[iOS 15] Nullptr crashes in ShareableBitmap::createGraphicsContext, mostly on twitter.com</short_desc>
          <delta_ts>2021-11-17 19:55:07 -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>Images</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="Ali Juma">ajuma</reporter>
          <assigned_to name="Cameron McCormack (:heycam)">heycam</assigned_to>
          <cc>heycam</cc>
    
    <cc>sabouhallawa</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>wenson_hsieh</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1815666</commentid>
    <comment_count>0</comment_count>
    <who name="Ali Juma">ajuma</who>
    <bug_when>2021-11-16 14:50:10 -0800</bug_when>
    <thetext>Chrome for iOS is getting crash reports in ShareableBitmap::createGraphicsContext, mostly (&gt; 50%) on twitter.com pages with large images. This is new in iOS 15.0, and is still occurring on iOS 15.2.

Looking for recent changes in the call stack, I wonder if this is related to r281661.

Here&apos;s the stack:
CRASHED [EXC_BAD_ACCESS / KERN_INVALID_ADDRESS @ 0x00000018 ] 
0x00000001923179a8 (WebKit + 0x003569a8)	WebKit::wantsExtendedRange(WebKit::ShareableBitmap::Configuration const&amp;)
0x0000000192317a08 (WebKit + 0x00356a08)	WebKit::ShareableBitmap::createGraphicsContext()
0x0000000192317a08 (WebKit + 0x00356a08)	WebKit::ShareableBitmap::createGraphicsContext()
0x0000000192317b58 (WebKit + 0x00356b58)	WebKit::ShareableBitmap::makeCGImageCopy()
0x00000001923ad30c (WebKit + 0x003ec30c)	WebKit::PageClientImpl::startDrag(WebCore::DragItem const&amp;, WebKit::ShareableBitmap::Handle const&amp;)
0x000000019274aba0 (WebKit + 0x00789ba0)	WebKit::WebPageProxy::didReceiveMessage(IPC::Connection&amp;, IPC::Decoder&amp;)
0x00000001920192cc (WebKit + 0x000582cc)	IPC::MessageReceiverMap::dispatchMessage(IPC::Connection&amp;, IPC::Decoder&amp;)
0x0000000192421a68 (WebKit + 0x00460a68)	WebKit::WebProcessProxy::didReceiveMessage(IPC::Connection&amp;, IPC::Decoder&amp;)
0x0000000191ff700c (WebKit + 0x0003600c)	IPC::Connection::dispatchMessage(std::__1::unique_ptr&lt;IPC::Decoder, std::__1::default_delete&lt;IPC::Decoder&gt; &gt;)
0x0000000191ff661c (WebKit + 0x0003561c)	IPC::Connection::dispatchIncomingMessages()
0x000000018f914778 (JavaScriptCore + 0x01133778)	WTF::RunLoop::performWork()
0x000000018f9158e8 (JavaScriptCore + 0x011348e8)	WTF::RunLoop::performWork(void*)
0x000000018395102c (CoreFoundation + 0x000bb02c)	__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
0x0000000183961cec (CoreFoundation + 0x000cbcec)	__CFRunLoopDoSource0
0x000000018389bff4 (CoreFoundation + 0x00005ff4)	__CFRunLoopDoSources0
0x00000001838a1800 (CoreFoundation + 0x0000b800)	__CFRunLoopRun
0x00000001838b53c4 (CoreFoundation + 0x0001f3c4)	CFRunLoopRunSpecific
0x000000019f0c6388 (GraphicsServices + 0x00001388)	GSEventRunModal
0x000000018625b05c (UIKitCore + 0x0051b05c)	-[UIApplication _run]
0x0000000185fd8b88 (UIKitCore + 0x00298b88)	UIApplicationMain</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1815685</commentid>
    <comment_count>1</comment_count>
    <who name="Cameron McCormack (:heycam)">heycam</who>
    <bug_when>2021-11-16 15:28:40 -0800</bug_when>
    <thetext>Thanks for the report, Ali.  There were a few changes to ShareableBitmap in the iOS 15 release.  I&apos;ll try to reproduce.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1815686</commentid>
    <comment_count>2</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2021-11-16 15:30:14 -0800</bug_when>
    <thetext>&lt;rdar://problem/85478309&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1815696</commentid>
    <comment_count>3</comment_count>
    <who name="Cameron McCormack (:heycam)">heycam</who>
    <bug_when>2021-11-16 15:51:13 -0800</bug_when>
    <thetext>It&apos;s possible ShareableBitmap::create returned null due to either numBytes overflowing  (though that would require something like a 32k x 32k image) or the ShareableBitmapMalloc::tryMalloc call failing.  Either way, PageClientImpl::startDrag should probably defend against ShareableBitmap::create returning null.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1815931</commentid>
    <comment_count>4</comment_count>
    <who name="Ali Juma">ajuma</who>
    <bug_when>2021-11-17 07:23:34 -0800</bug_when>
    <thetext>(In reply to Cameron McCormack (:heycam) from comment #3)
&gt; It&apos;s possible ShareableBitmap::create returned null due to either numBytes
&gt; overflowing  (though that would require something like a 32k x 32k image) or
&gt; the ShareableBitmapMalloc::tryMalloc call failing.  Either way,
&gt; PageClientImpl::startDrag should probably defend against
&gt; ShareableBitmap::create returning null.

Thanks for having a look. A large fraction of the crash reports are happening when free memory is low, so it&apos;s probably the ShareableBitmapMalloc::tryMalloc call failing.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1816059</commentid>
    <comment_count>5</comment_count>
    <who name="Cameron McCormack (:heycam)">heycam</who>
    <bug_when>2021-11-17 12:30:54 -0800</bug_when>
    <thetext>(In reply to Ali Juma from comment #4)
&gt; Thanks for having a look. A large fraction of the crash reports are
&gt; happening when free memory is low, so it&apos;s probably the
&gt; ShareableBitmapMalloc::tryMalloc call failing.

Oh actually this is the ShareableBitmap::create call that takes a shared memory handle, so there&apos;s no allocation failure here.  But there are still paths where we can return null (mapping the shared memory failing, or numBytes is too big, or the shared memory size not matching the number of bytes we expect).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1816131</commentid>
    <comment_count>6</comment_count>
      <attachid>444579</attachid>
    <who name="Cameron McCormack (:heycam)">heycam</who>
    <bug_when>2021-11-17 14:33:09 -0800</bug_when>
    <thetext>Created attachment 444579
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1816285</commentid>
    <comment_count>7</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2021-11-17 19:55:05 -0800</bug_when>
    <thetext>Committed r285976 (244373@main): &lt;https://commits.webkit.org/244373@main&gt;

All reviewed patches have been landed. Closing bug and clearing flags on attachment 444579.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>444579</attachid>
            <date>2021-11-17 14:33:09 -0800</date>
            <delta_ts>2021-11-17 19:55:06 -0800</delta_ts>
            <desc>Patch</desc>
            <filename>bug-233217-20211118093308.patch</filename>
            <type>text/plain</type>
            <size>1518</size>
            <attacher name="Cameron McCormack (:heycam)">heycam</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjg1OTEzCmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViS2l0L0No
YW5nZUxvZyBiL1NvdXJjZS9XZWJLaXQvQ2hhbmdlTG9nCmluZGV4IDhmMWQ4OTEwNDI2Njk0OWQ2
NGFlYWRhMDQwMGUxNjcxYzRkYTQ1MjUuLjQwODlmMzkyZDR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