Summary: | [WK2][GTK] WebProcess SIGSEVs due to incorrect clipboard handling | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Sergio Villar Senin <svillar> | ||||||
Component: | WebKitGTK | Assignee: | Sergio Villar Senin <svillar> | ||||||
Status: | RESOLVED FIXED | ||||||||
Severity: | Normal | CC: | mrobinson, svillar | ||||||
Priority: | P2 | ||||||||
Version: | 528+ (Nightly build) | ||||||||
Hardware: | Unspecified | ||||||||
OS: | Unspecified | ||||||||
Bug Depends on: | |||||||||
Bug Blocks: | 76070 | ||||||||
Attachments: |
|
Description
Sergio Villar Senin
2012-02-22 09:54:02 PST
Created attachment 128235 [details]
Patch
Comment on attachment 128235 [details]
Patch
Looks good to me
Comment on attachment 128235 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=128235&action=review > Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp:141 > static Frame* frameSettingClipboard; > static void collapseSelection(GtkClipboard* clipboard, Frame* frame) > { > - if (frameSettingClipboard && frameSettingClipboard == frame) > - return; > + if (!frameSettingClipboard || frameSettingClipboard != frame) > + // Collapse the selection without clearing it. > + frame->selection()->setBase(frame->selection()->extent(), frame->selection()->affinity()); > > - // Collapse the selection without clearing it. > - ASSERT(frame); > - frame->selection()->setBase(frame->selection()->extent(), frame->selection()->affinity()); > + frame->deref(); > } I think that manually referencing the frame here is the wrong approach. Intead of hanging on to the frame, WebKit1 keeps a reference to the WebView and uses corePage->focusController()->focusedOrMainFrame(). Another approach is to figure out a way to detect when the frame dies and to clear frameSettingClipboard then. (In reply to comment #3) > I think that manually referencing the frame here is the wrong approach. Intead of hanging on to the frame, WebKit1 keeps a reference to the WebView and uses corePage->focusController()->focusedOrMainFrame(). Another approach is to figure out a way to detect when the frame dies and to clear frameSettingClipboard then. In WebKit1 we're not exactly keeping a reference to the WebView, it's just a pointer. The difference is that WebKit1 uses g_cclosure_new_object() that ensures that the callback is not called once the object passed as argument is unref'ed. Anyway the platform independent WK2 WebEditorClient.cpp has a WebEditorClient::pageDestroyed() method. What about adding there a call (#ifdef'ed for GTK) to clear the frameSettingClipboard ? (In reply to comment #4) > Anyway the platform independent WK2 WebEditorClient.cpp has a WebEditorClient::pageDestroyed() method. What about adding there a call (#ifdef'ed for GTK) to clear the frameSettingClipboard ? That makes sense, but in that case you should keep a reference to the Page instead of the Frame. A Frame can be destroyed before its owning Page. Created attachment 128268 [details]
Patch
(In reply to comment #6) > Created an attachment (id=128268) [details] > Patch This new approach uses a frame destructor object in combination with gclosure finalization notifications to fix the bug. Comment on attachment 128268 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=128268&action=review Great use of FrameDestructionObserver. > Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp:136 > + explicit EditorClientFrameDestructionObserver(Frame* frame, GClosure* closure) I think you can omit "explicit" here. > Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp:143 > + void frameDestroyed() { g_closure_invalidate(m_closure); FrameDestructionObserver::frameDestroyed(); } I'd prefer this to be two spread over multiple lines. > Source/WebKit2/WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp:150 > + EditorClientFrameDestructionObserver* observer = static_cast<EditorClientFrameDestructionObserver*>(data); > + delete observer; You can just do: delete data; Committed r108631: <http://trac.webkit.org/changeset/108631> |