Bug 95118 - Hook procedure should check to see if hook has already been removed before attempting removal.
Summary: Hook procedure should check to see if hook has already been removed before at...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Windows 7
: P2 Normal
Assignee: Roger Fong
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2012-08-27 13:19 PDT by Roger Fong
Modified: 2012-08-27 15:18 PDT (History)
5 users (show)

See Also:


Attachments
patch (2.02 KB, patch)
2012-08-27 13:46 PDT, Roger Fong
no flags Details | Formatted Diff | Diff
typo in Changelog (2.02 KB, patch)
2012-08-27 13:54 PDT, Roger Fong
simon.fraser: review+
Details | Formatted Diff | Diff
more typos/clarification (2.20 KB, patch)
2012-08-27 14:16 PDT, Roger Fong
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Roger Fong 2012-08-27 13:19:27 PDT
When the hookFired method in LayerChangesFlusher.cpp gets called it calls CallNextHook to pass the message to the next hook procedure in the hook chain.

However, sometimes, the hook procedure it gets passed to can dispatch another message that goes back through the hook chain and causes the hookFired method to get called again (before returning from CallNextHookEx).

When the second hookFired call completes, it can remove the hook. 
When CallNextHook returns the original call to hookFired may try to remove the hook as well. However, there is no need as the hook as already been removed and in fact we get an assertion failure assert(m_hook) when we try to call removeHook().

The fix is simply to check to see that m_hook is not null before calling into removeHook, so we don't waste effort trying to remove a hook that has already been removed.

Alternatively, I could just remove the assert but then just call UnhookWindowHookEx regardless of whether the hook has already been removed or not, but that seems a little sketchy to me...
Comment 1 Radar WebKit Bug Importer 2012-08-27 13:20:12 PDT
<rdar://problem/12182019>
Comment 2 Roger Fong 2012-08-27 13:28:51 PDT
> However, sometimes, the hook procedure it gets passed to can dispatch another message that goes back through the hook chain and causes the hookFired method to get called again (before returning from CallNextHookEx).

I think I missed half a sentence...: 
Sometimes, the hook procedure can passed to another hook procedure that can dispatch another message. This message goes back through the hook chain and causes the hookFired method to get called again (before returning from CallNextHookEx).
Comment 3 Roger Fong 2012-08-27 13:46:40 PDT
Created attachment 160795 [details]
patch
Comment 4 Roger Fong 2012-08-27 13:54:33 PDT
Created attachment 160798 [details]
typo in Changelog
Comment 5 Simon Fraser (smfr) 2012-08-27 13:55:28 PDT
Comment on attachment 160798 [details]
typo in Changelog

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

> Source/WebCore/ChangeLog:8
> +        Sometimes, the hook procedure can passed to another hook procedure that can dispatch another message. 

"can passed to"?

> Source/WebCore/ChangeLog:9
> +        This message goes back through the hook chain and causes the hookFired method to get called again 

Are you saying that it can re-enter?
Comment 6 Roger Fong 2012-08-27 14:16:55 PDT
Created attachment 160803 [details]
more typos/clarification
Comment 7 WebKit Review Bot 2012-08-27 15:18:43 PDT
Comment on attachment 160803 [details]
more typos/clarification

Clearing flags on attachment: 160803

Committed r126805: <http://trac.webkit.org/changeset/126805>
Comment 8 WebKit Review Bot 2012-08-27 15:18:47 PDT
All reviewed patches have been landed.  Closing bug.