<?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>223832</bug_id>
          
          <creation_ts>2021-03-26 17:42:39 -0700</creation_ts>
          <short_desc>Safari crashed and lost all tabs, after unlocking sleeping device</short_desc>
          <delta_ts>2021-03-30 11:56:11 -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>WebKit Misc.</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>REOPENED</bug_status>
          <resolution></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="Jiewen Tan">jiewen_tan</reporter>
          <assigned_to name="Jiewen Tan">jiewen_tan</assigned_to>
          <cc>bfulgham</cc>
    
    <cc>ddkilzer</cc>
    
    <cc>ggaren</cc>
    
    <cc>jiewen_tan</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1744411</commentid>
    <comment_count>0</comment_count>
    <who name="Jiewen Tan">jiewen_tan</who>
    <bug_when>2021-03-26 17:42:39 -0700</bug_when>
    <thetext>Safari crashed and lost all tabs, after unlocking sleeping device.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1744412</commentid>
    <comment_count>1</comment_count>
    <who name="Jiewen Tan">jiewen_tan</who>
    <bug_when>2021-03-26 17:42:49 -0700</bug_when>
    <thetext>rdar://75555287</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1744416</commentid>
    <comment_count>2</comment_count>
      <attachid>424426</attachid>
    <who name="Jiewen Tan">jiewen_tan</who>
    <bug_when>2021-03-26 17:49:31 -0700</bug_when>
    <thetext>Created attachment 424426
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1744508</commentid>
    <comment_count>3</comment_count>
      <attachid>424426</attachid>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2021-03-27 08:43:00 -0700</bug_when>
    <thetext>Comment on attachment 424426
Patch

r=me</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1744515</commentid>
    <comment_count>4</comment_count>
      <attachid>424426</attachid>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2021-03-27 09:59:12 -0700</bug_when>
    <thetext>Comment on attachment 424426
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=424426&amp;action=review

&gt; Source/WebKit/ChangeLog:11
&gt; +        A speculative fix for this crash. A possible explanation from the crash log suggests that the protectedThis
&gt; +        could be elided because of compiler optimization given it is not used in the block. To prevent such optimization,
&gt; +        protectedThis is therefore used explicitly in the block.

Is there a reason to stop at speculation? This would be visible in disassembly of the build where this occurred.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1744818</commentid>
    <comment_count>5</comment_count>
    <who name="Jiewen Tan">jiewen_tan</who>
    <bug_when>2021-03-29 12:00:31 -0700</bug_when>
    <thetext>(In reply to Alexey Proskuryakov from comment #4)
&gt; Comment on attachment 424426 [details]
&gt; Patch
&gt; 
&gt; View in context:
&gt; https://bugs.webkit.org/attachment.cgi?id=424426&amp;action=review
&gt; 
&gt; &gt; Source/WebKit/ChangeLog:11
&gt; &gt; +        A speculative fix for this crash. A possible explanation from the crash log suggests that the protectedThis
&gt; &gt; +        could be elided because of compiler optimization given it is not used in the block. To prevent such optimization,
&gt; &gt; +        protectedThis is therefore used explicitly in the block.
&gt; 
&gt; Is there a reason to stop at speculation? This would be visible in
&gt; disassembly of the build where this occurred.

Can we get this info just from the crash reports?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1745035</commentid>
    <comment_count>6</comment_count>
      <attachid>424426</attachid>
    <who name="Jiewen Tan">jiewen_tan</who>
    <bug_when>2021-03-29 23:31:45 -0700</bug_when>
    <thetext>Comment on attachment 424426
Patch

Thanks Dave for r+ this patch.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1745036</commentid>
    <comment_count>7</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2021-03-29 23:35:18 -0700</bug_when>
    <thetext>Committed r275197: &lt;https://commits.webkit.org/r275197&gt;

All reviewed patches have been landed. Closing bug and clearing flags on attachment 424426.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1745162</commentid>
    <comment_count>8</comment_count>
      <attachid>424426</attachid>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2021-03-30 10:03:59 -0700</bug_when>
    <thetext>Comment on attachment 424426
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=424426&amp;action=review

&gt;&gt;&gt; Source/WebKit/ChangeLog:11
&gt;&gt;&gt; +        protectedThis is therefore used explicitly in the block.
&gt;&gt; 
&gt;&gt; Is there a reason to stop at speculation? This would be visible in disassembly of the build where this occurred.
&gt; 
&gt; Can we get this info just from the crash reports?

You can get this information as follows:

(1) otool -tvV /path/to/WebKit

(2) type &apos;/&apos; to do a regex search

(3) search for dismissViewController (the function names will be mangled; you can use c++filt to unmangle a name and be sure you&apos;ve got the right one)

(4) see if the disassembled code contains calls to ref/deref or, more likely, since ref/deref are usually inlined, see if there&apos;s a call to the SOAuthorizationSession operator delete or destructor (which would happen in the unlikely deref path).

But also:

This theory of the bug is definitely wrong. The compiler has no basis to eliminate a capture when the act of capturing obviously has side effects (by calling ref() in the capture and deref() when out of scope). Also, if the compiler did have such a bug, other WebKit code would crash all the time.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1745163</commentid>
    <comment_count>9</comment_count>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2021-03-30 10:04:25 -0700</bug_when>
    <thetext>I think we should revert this patch and continue investigating. If you&apos;d like to do the otool exercise first, to prove the patch had no effect, that&apos;s OK too.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1745165</commentid>
    <comment_count>10</comment_count>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2021-03-30 10:07:32 -0700</bug_when>
    <thetext>To explain more, the reason I think we should revert is that it is harmful to have &quot;spooky&quot; code that is not verified by any test, and that contradicts our mental model of the computer. Once we enter that spooky universe / weird machine state, it is no longer possible to reason about our code, or understand whether future changes are OK or not.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1745213</commentid>
    <comment_count>11</comment_count>
      <attachid>424426</attachid>
    <who name="Jiewen Tan">jiewen_tan</who>
    <bug_when>2021-03-30 11:51:26 -0700</bug_when>
    <thetext>Comment on attachment 424426
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=424426&amp;action=review

&gt;&gt;&gt;&gt; Source/WebKit/ChangeLog:11
&gt;&gt;&gt;&gt; +        protectedThis is therefore used explicitly in the block.
&gt;&gt;&gt; 
&gt;&gt;&gt; Is there a reason to stop at speculation? This would be visible in disassembly of the build where this occurred.
&gt;&gt; 
&gt;&gt; Can we get this info just from the crash reports?
&gt; 
&gt; You can get this information as follows:
&gt; 
&gt; (1) otool -tvV /path/to/WebKit
&gt; 
&gt; (2) type &apos;/&apos; to do a regex search
&gt; 
&gt; (3) search for dismissViewController (the function names will be mangled; you can use c++filt to unmangle a name and be sure you&apos;ve got the right one)
&gt; 
&gt; (4) see if the disassembled code contains calls to ref/deref or, more likely, since ref/deref are usually inlined, see if there&apos;s a call to the SOAuthorizationSession operator delete or destructor (which would happen in the unlikely deref path).
&gt; 
&gt; But also:
&gt; 
&gt; This theory of the bug is definitely wrong. The compiler has no basis to eliminate a capture when the act of capturing obviously has side effects (by calling ref() in the capture and deref() when out of scope). Also, if the compiler did have such a bug, other WebKit code would crash all the time.

Let&apos;s revert the code change then.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1745217</commentid>
    <comment_count>12</comment_count>
    <who name="Jiewen Tan">jiewen_tan</who>
    <bug_when>2021-03-30 11:56:11 -0700</bug_when>
    <thetext>Reverted r275197 for reason:

The change is spooky.

Committed r275219 (235913@main): &lt;https://commits.webkit.org/235913@main&gt;</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>424426</attachid>
            <date>2021-03-26 17:49:31 -0700</date>
            <delta_ts>2021-03-29 23:35:18 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-223832-20210326174930.patch</filename>
            <type>text/plain</type>
            <size>3883</size>
            <attacher name="Jiewen Tan">jiewen_tan</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjc1MTA1CmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViS2l0L0No
YW5nZUxvZyBiL1NvdXJjZS9XZWJLaXQvQ2hhbmdlTG9nCmluZGV4IGU5NTg3ZjVkZjNjNDNmNjNk
YTg5NmIwZWQxNWJmMjllZTk4ZDFkNjEuLjE4NjlmOTJmYzllN2VmNGZmYWMxYjNjNzM3ZWUwM2Jm
Yjk0NTg5MWEgMTAwNjQ0Ci0tLSBhL1NvdXJjZS9XZWJLaXQvQ2hhbmdlTG9nCisrKyBiL1NvdXJj
ZS9XZWJLaXQvQ2hhbmdlTG9nCkBAIC0xLDMgKzEsMTggQEAKKzIwMjEtMDMtMjYgIEppZXdlbiBU
YW4gIDxqaWV3ZW5fdGFuQGFwcGxlLmNvbT4KKworICAgICAgICBTYWZhcmkgY3Jhc2hlZCBhbmQg
bG9zdCBhbGwgdGFicywgYWZ0ZXIgdW5sb2NraW5nIHNsZWVwaW5nIGRldmljZQorICAgICAgICBo
dHRwczovL2J1Z3Mud2Via2l0Lm9yZy9zaG93X2J1Zy5jZ2k/aWQ9MjIzODMyCisgICAg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