<?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>62248</bug_id>
          
          <creation_ts>2011-06-07 16:08:35 -0700</creation_ts>
          <short_desc>WKResponderChainSink mechanism isn&apos;t robust against some types of responder chain manipulation</short_desc>
          <delta_ts>2011-06-07 17:45:07 -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>WebKit2</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</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="John Sullivan">sullivan</reporter>
          <assigned_to name="John Sullivan">sullivan</assigned_to>
          <cc>darin</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>416894</commentid>
    <comment_count>0</comment_count>
    <who name="John Sullivan">sullivan</who>
    <bug_when>2011-06-07 16:08:35 -0700</bug_when>
    <thetext>WebKit2&apos;s WKResponderChainSink mechanism assumes that no other code has modified the responder chain during the lifetime of this WKResponderChainSink. That&apos;s generally a decent assumption, because the lifetime of these objects (as currently used) is wrapped around a single call to [super doCommandBySelector:]. But if that call ends up modifying the responder chain, [WKResponderChainSink detach] can modify it again in the wrong way, leaving itself in the responder chain even after it has been dealloc&apos;ed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>416913</commentid>
    <comment_count>1</comment_count>
      <attachid>96326</attachid>
    <who name="John Sullivan">sullivan</who>
    <bug_when>2011-06-07 16:27:52 -0700</bug_when>
    <thetext>Created attachment 96326
Patch to make [WKResponderChainSink detach] robust against some kinds of responder chain manipulations</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>416923</commentid>
    <comment_count>2</comment_count>
      <attachid>96326</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2011-06-07 16:39:15 -0700</bug_when>
    <thetext>Comment on attachment 96326
Patch to make [WKResponderChainSink detach] robust against some kinds of responder chain manipulations

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

&gt; Source/WebKit2/UIProcess/API/mac/WKView.mm:2527
&gt; +    // This assumes that the responder chain was either unmodified since
&gt; +    // -initWithResponderChain: was called, or was modified in such a way
&gt; +    // that _lastResponderInChain is still in the chain, and self was not
&gt; +    // moved earlier in the chain than _lastResponderInChain.

Another technique would be to start with -[NSWindow firstResponder] and search for self in that chain. We could do that instead of saving _lastResponderInChain. Or we could do both to make sure we’re removed if either technique finds us.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>416924</commentid>
    <comment_count>3</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2011-06-07 16:39:25 -0700</bug_when>
    <thetext>Patch is OK as is.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>416948</commentid>
    <comment_count>4</comment_count>
    <who name="John Sullivan">sullivan</who>
    <bug_when>2011-06-07 17:21:17 -0700</bug_when>
    <thetext>I thought about starting with the window’s first responder, but that would be a bigger change for what I needed to work here, and still not guaranteed to find every possible kind of responder chain manipulation. Note that the WKResponderChainSink is not an NSView so it isn’t associated with a window. So to start with the window’s first responder would require that the WKResponderChainSink keeps track of either a window or an NSView. It could be changed to require an NSView rather than an NSResponder in its init method, and then store that NSView and use it to get the window and then start with the first responder in -detach. That would be a little more work in detach since it would have to walk (nearly) the entire responder chain every time instead of just calling nextResponder once in the common case as it does with my patch. As you say, the combination of the two approaches would be more robust, but seemed a little like overkill for now.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>416970</commentid>
    <comment_count>5</comment_count>
    <who name="John Sullivan">sullivan</who>
    <bug_when>2011-06-07 17:45:07 -0700</bug_when>
    <thetext>Fixed in http://trac.webkit.org/changeset/88298</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>96326</attachid>
            <date>2011-06-07 16:27:52 -0700</date>
            <delta_ts>2011-06-07 16:39:15 -0700</delta_ts>
            <desc>Patch to make [WKResponderChainSink detach] robust against some kinds of responder chain manipulations</desc>
            <filename>62248_patch.txt</filename>
            <type>text/plain</type>
            <size>2312</size>
            <attacher name="John Sullivan">sullivan</attacher>
            
              <data encoding="base64">SW5kZXg6IFNvdXJjZS9XZWJLaXQyL0NoYW5nZUxvZwo9PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBTb3VyY2UvV2Vi
S2l0Mi9DaGFuZ2VMb2cJKHJldmlzaW9uIDg4MjgwKQorKysgU291cmNlL1dlYktpdDIvQ2hhbmdl
TG9nCSh3b3JraW5nIGNvcHkpCkBAIC0xLDMgKzEsMjAgQEAKKzIwMTEtMDYtMDcgIEpvaG4gU3Vs
bGl2YW4gIDxzdWxsaXZhbkBhcHBsZS5jb20+CisKKyAgICAgICAgUmV2aWV3ZWQgYnkgTk9CT0RZ
IChPT1BTISkuCisKKyAgICAgICAgPGh0dHBzOi8vYnVncy53ZWJraXQub3JnL3Nob3dfYnVnLmNn
aT9pZD02MjI0OD4KKyAgICAgICAgPHJkYXI6Ly9wcm9ibGVtLzk1Njg1MTY+CisgICAgICAgIFdL
UmVzcG9uZGVyQ2hhaW5TaW5rIG1lY2hhbmlzbSBpc24ndCByb2J1c3QgYWdhaW5zdCBzb21lIHR5
cGVzIG9mIHJlc3BvbmRlciBjaGFpbiBtYW5pcHVsYXRpb24KKworICAgICAgICAqIFVJUHJvY2Vz
c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ZSBhcmUgbm8gbG9uZ2VyIGluIHRoZSByZXNwb25kZXIgY2hhaW4uCisgICAg
aWYgKG5leHQgIT0gc2VsZikKKyAgICAgICAgcmV0dXJuOworICAgIAorICAgIFtyZXNwb25kZXJC
ZWZvcmVTZWxmIHNldE5leHRSZXNwb25kZXI6W3NlbGYgbmV4dFJlc3BvbmRlcl1dOwogICAgIF9s
YXN0UmVzcG9uZGVySW5DaGFpbiA9IG5pbDsKIH0KIAo=
</data>
<flag name="review"
          id="89986"
          type_id="1"
          status="+"
          setter="darin"
    />
          </attachment>
      

    </bug>

</bugzilla>