RESOLVED FIXED 44935
[Qt] Web process crash when pressing modifiers in input field
https://bugs.webkit.org/show_bug.cgi?id=44935
Summary [Qt] Web process crash when pressing modifiers in input field
Kimmo Kinnunen
Reported 2010-08-31 01:39:08 PDT
Created attachment 66021 [details] patch describing the point of the crash Web process crashes when pressing modifiers in input field Null pointer reference in PlatformKeyboardEvent.
Attachments
patch describing the point of the crash (5.06 KB, patch)
2010-08-31 01:39 PDT, Kimmo Kinnunen
no flags
Patch fixing the crash (8.11 KB, patch)
2010-08-31 04:14 PDT, Kimmo Kinnunen
no flags
Patch try #2 (7.31 KB, patch)
2010-10-05 05:46 PDT, Kimmo Kinnunen
no flags
Fix for the test regression (2.17 KB, patch)
2010-10-05 08:16 PDT, Kimmo Kinnunen
no flags
keyIdentifierForQtKeyCode compiled by probably not exceptionally "smart" compiler (9.41 KB, text/plain)
2010-10-05 22:58 PDT, Kimmo Kinnunen
no flags
disambiguateKeyDownEvent compiled (1.25 KB, text/plain)
2010-10-05 23:31 PDT, Kimmo Kinnunen
no flags
Kimmo Kinnunen
Comment 1 2010-08-31 04:14:03 PDT
Created attachment 66029 [details] Patch fixing the crash
Ariya Hidayat
Comment 2 2010-08-31 05:29:50 PDT
Comment on attachment 66029 [details] Patch fixing the crash > +#if defined(XP_UNIX) > +uint32_t PlatformKeyboardEvent::x11NativeModifiers() const > +{ > + ASSERT(m_qtEvent); > + return m_qtEvent->nativeModifiers(); > +} > + > +uint32_t PlatformKeyboardEvent::x11NativeScanCode() const > +{ > + ASSERT(m_qtEvent); > + return m_qtEvent->nativeScanCode(); > +} > +#endif This is confusing. Can you explain what is the reason behind introducing these two Unix-only functions?
Kimmo Kinnunen
Comment 3 2010-08-31 06:17:41 PDT
(In reply to comment #2) > (From update of attachment 66029 [details]) > > +#if defined(XP_UNIX) > > +uint32_t PlatformKeyboardEvent::x11NativeModifiers() const > > +{ > > + ASSERT(m_qtEvent); > > + return m_qtEvent->nativeModifiers(); > > +} > > + > > +uint32_t PlatformKeyboardEvent::x11NativeScanCode() const > > +{ > > + ASSERT(m_qtEvent); > > + return m_qtEvent->nativeScanCode(); > > +} > > +#endif > > This is confusing. Can you explain what is the reason behind introducing these two Unix-only functions? The idea is that X11 plugins can be supported even though PlatformKeyboardEvent may not be instantiated from QKeyEvent In other words: the implementation tries to remove the notion that PlatformKeyboardEvent is QKeyEvent. Otherwise we must synthetize QKeyEvent from WebKeyboardEvent. This is a bit redundant. On top of redundancy, this is not even possible, because there's no such a constructor for QKeyEvent (X11 Qt uses QKeyEventEx internally)
Ariya Hidayat
Comment 4 2010-09-02 23:35:52 PDT
> In other words: the implementation tries to remove the notion that PlatformKeyboardEvent is QKeyEvent. I did not ask what the patch is doing, which is quite clear, but rather why it is implemented that way. Here is what I had in mind when thinking about this problem. There will be nativeModifiers() and nativeScanCode() for PlatformKeyboardEvent under #if PLATFORM(QT), i.e. no need to specialize for XP_UNIX. Can this work?
Kimmo Kinnunen
Comment 5 2010-09-02 23:42:27 PDT
(In reply to comment #4) > > In other words: the implementation tries to remove the notion that PlatformKeyboardEvent is QKeyEvent. > > I did not ask what the patch is doing, which is quite clear, but rather why it is implemented that way. > > Here is what I had in mind when thinking about this problem. There will be nativeModifiers() and nativeScanCode() for PlatformKeyboardEvent under #if PLATFORM(QT), i.e. no need to specialize for XP_UNIX. Can this work? You mean that remove the #if XP_UNIX and remove the x11 prefix? Should work, though I don't see any point where the other qt platforms use the methods. It's ok for me, if it's ok for you.
Ariya Hidayat
Comment 6 2010-09-03 00:49:34 PDT
> You mean that remove the #if XP_UNIX and remove the x11 prefix? Should work, though I don't see any point where the other qt platforms use the methods. It's ok for me, if it's ok for you. IMHO it makes the code more readable and less confusing.
Kimmo Kinnunen
Comment 7 2010-10-05 05:46:33 PDT
Created attachment 69773 [details] Patch try #2 Patch addressing the comments.
WebKit Commit Bot
Comment 8 2010-10-05 06:28:53 PDT
Comment on attachment 69773 [details] Patch try #2 Clearing flags on attachment: 69773 Committed r69105: <http://trac.webkit.org/changeset/69105>
WebKit Commit Bot
Comment 9 2010-10-05 06:28:58 PDT
All reviewed patches have been landed. Closing bug.
Csaba Osztrogonác
Comment 10 2010-10-05 07:42:57 PDT
(In reply to comment #8) > (From update of attachment 69773 [details]) > Clearing flags on attachment: 69773 > > Committed r69105: <http://trac.webkit.org/changeset/69105> It broke plugins/keyboard-events.html on Qt bot: http://build.webkit.org/results/Qt%20Linux%20Release/r69105%20%2821509%29/plugins/keyboard-events-pretty-diff.html
Kimmo Kinnunen
Comment 11 2010-10-05 08:01:00 PDT
reopening due to a regression.
Kimmo Kinnunen
Comment 12 2010-10-05 08:16:41 PDT
Created attachment 69785 [details] Fix for the test regression
Balazs Kelemen
Comment 13 2010-10-05 08:59:12 PDT
Comment on attachment 69773 [details] Patch try #2 View in context: https://bugs.webkit.org/attachment.cgi?id=69773&action=review > WebCore/platform/qt/PlatformKeyboardEventQt.cpp:579 > +} We should reorganize the members in the enum to do this test it in O(1). Do you agree?
Csaba Osztrogonác
Comment 14 2010-10-05 09:05:58 PDT
(In reply to comment #13) > (From update of attachment 69773 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=69773&action=review > > > WebCore/platform/qt/PlatformKeyboardEventQt.cpp:579 > > +} > > We should reorganize the members in the enum to do this test it in O(1). Do you agree? It isn't an enum, but defines. We don't need to reorganize it, because GCC (and other compilers) generates a jump table for this case construction to execute the binary in O(1). ;)
Balazs Kelemen
Comment 15 2010-10-05 09:51:13 PDT
(In reply to comment #14) > (In reply to comment #13) > > (From update of attachment 69773 [details] [details]) > > View in context: https://bugs.webkit.org/attachment.cgi?id=69773&action=review > > > > > WebCore/platform/qt/PlatformKeyboardEventQt.cpp:579 > > > +} > > > > We should reorganize the members in the enum to do this test it in O(1). Do you agree? > > It isn't an enum, but defines. Doesn't matter. > We don't need to reorganize it, > because GCC (and other compilers) generates a jump table > for this case construction to execute the binary in O(1). ;) Hm, are you sure? It could do that but I am afraid that the compiler is not so clever (or at least not all the compilers). Do you have an experience about that?
WebKit Commit Bot
Comment 16 2010-10-05 12:13:10 PDT
Comment on attachment 69785 [details] Fix for the test regression Clearing flags on attachment: 69785 Committed r69134: <http://trac.webkit.org/changeset/69134>
WebKit Commit Bot
Comment 17 2010-10-05 12:13:16 PDT
All reviewed patches have been landed. Closing bug.
Kimmo Kinnunen
Comment 18 2010-10-05 22:55:29 PDT
(In reply to comment #13) > (From update of attachment 69773 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=69773&action=review > > > WebCore/platform/qt/PlatformKeyboardEventQt.cpp:579 > > +} > > We should reorganize the members in the enum to do this test it in O(1). Do you agree? We should, especially if it shows up in your profiles as a hotspot. Did it? It really doesn't show up for me, though, so it seems a bit of a wasted effort, effort which I would like to spend in some other place. I don't know the optimization technique. I cannot modify the enum as it is implemented in Qt. Do you mean that the order of the case statements should match the order of the enum values? I'll attach an example output from my compiler. I'm no expert in this, so I cannot say for sure, but something seems to be rearranged by the looks of it. If the output doesn't match your expectation, feel free to rearrange switch.
Kimmo Kinnunen
Comment 19 2010-10-05 22:58:06 PDT
Created attachment 69891 [details] keyIdentifierForQtKeyCode compiled by probably not exceptionally "smart" compiler
Kimmo Kinnunen
Comment 20 2010-10-05 23:16:32 PDT
Comment on attachment 69891 [details] keyIdentifierForQtKeyCode compiled by probably not exceptionally "smart" compiler oops, I noticed we were talking about different function.
Kimmo Kinnunen
Comment 21 2010-10-05 23:31:35 PDT
Created attachment 69894 [details] disambiguateKeyDownEvent compiled Again, I'm no expert, but i think the switch is compiled to following sequence: .loc 1 505 0 cmp r1, #111 bgt .L399 cmp r1, #96 bge .L398 cmp r1, #57 bgt .L400 cmp r1, #48 bge .L398 cmp r1, #32 beq .L398
Balazs Kelemen
Comment 22 2010-10-06 02:29:24 PDT
Seems to be optimized enough. Thanks for dealing with that.
Note You need to log in before you can comment on or make changes to this bug.