<?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>228901</bug_id>
          
          <creation_ts>2021-08-07 18:47:06 -0700</creation_ts>
          <short_desc>UBSan: KeyboardScrollingAnimator.cpp:303:10: runtime error: load of value nnn, which is not a valid value for type &apos;bool&apos;</short_desc>
          <delta_ts>2021-08-07 21:18: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>WebCore Misc.</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=176131</see_also>
          <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>
          <dependson>228009</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="David Kilzer (:ddkilzer)">ddkilzer</reporter>
          <assigned_to name="David Kilzer (:ddkilzer)">ddkilzer</assigned_to>
          <cc>dana.estra</cc>
    
    <cc>thorton</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1782745</commentid>
    <comment_count>0</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2021-08-07 18:47:06 -0700</bug_when>
    <thetext>UBSan: KeyboardScrollingAnimator.cpp:303:10: runtime error: load of value nnn, which is not a valid value for type &apos;bool&apos;

Occurs here:

    void KeyboardScrollingAnimator::handleKeyUpEvent()
    {
        if (!m_scrollTriggeringKeyIsPressed)   // UBSan warning
            return;

        stopKeyboardScrollAnimation();
        m_scrollTriggeringKeyIsPressed = false;
    }

Caused by the m_wasAccumulatingRepaintRegion instance variable not being initialized:

    class KeyboardScrollingAnimator {
        [...]
    private:
        [...]
        bool m_scrollTriggeringKeyIsPressed;  // BUG: No default initialization.
        [...]
    };

Affects the following 78 layout tests:

accessibility/aria-slider-value-change.html
accessibility/insert-children-assert.html
accessibility/mac/focus-moves-cursor.html
accessibility/mac/input-type-change-crash-2.html
accessibility/mac/input-type-change-crash.html
accessibility/mac/selection-initial.html
accessibility/mac/text-marker-line-boundary.html
accessibility/spinbutton-crash.html
editing/caret/emoji.html
editing/deleting/5729680.html
editing/input/caret-at-the-edge-of-input.html
editing/input/cocoa/autocorrect-off.html
editing/inserting/typing-tab-designmode-forms.html
editing/mac/deleting/backward-delete.html
editing/mac/spelling/autocorrection-blockquote-crash.html
editing/pasteboard/emacs-ctrl-a-k-y.html
editing/selection/context-menu-text-selection-lookup.html
editing/selection/move-begin-end.html
editing/selection/verify-editing-behavior-for-line-granularity.html
fast/dom/MutationObserver/inline-event-listener.html
fast/dom/access-key-iframe.html
fast/dom/fragment-activation-focuses-target.html
fast/dom/hidden-iframe-no-focus.html
fast/dom/mutation-details-focus.html
fast/events/autoscroll-should-not-stop-on-keypress.html
fast/events/beforeunload-alert-handled-keydown.html
fast/events/event-input-contentEditable.html
fast/events/focus-label-legend-elements-with-tab.html
fast/events/select-element.html
fast/events/tab-focus-anchor.html
fast/forms/access-key-case-insensitive.html
fast/forms/call-text-did-change-in-text-field-when-typing.html
fast/forms/datalist/datalist-option-labels.html
fast/forms/datetimelocal/datetimelocal-editable-components/datetimelocal-editable-components-keyboard-events.html
fast/forms/disabled-search-input.html
fast/forms/input-first-letter-edit.html
fast/forms/legend-access-key.html
fast/forms/month/month-editable-components/month-editable-components-focus-and-blur-events.html
fast/forms/onchange-enter-submit.html
fast/forms/radio/input-radio-checked-tab.html
fast/forms/range/range-keyboard-oninput-event.html
fast/forms/search-event-delay.html
fast/forms/tabbing-input-iframe.html
fast/forms/time/time-editable-components/time-editable-components-focus-and-blur-events.html
fast/forms/validation-message-maxLength.html
fast/frames/focus-controller-crash-change-event.html
fast/frames/iframe-window-focus.html
fast/html/details-keyboard-show-hide.html
fast/html/progress-user-modify.html
fast/repaint/fixed-move-after-keyboard-scroll.html
fast/scrolling/arrow-key-scroll-in-rtl-document.html
fast/text/scroll-text-overflow-ellipsis.html
fullscreen/full-screen-crash-custom-scrollbars.html
fullscreen/full-screen-iframe-allowed-prefixed.html
fullscreen/full-screen-table-section.html
http/tests/fullscreen/fullscreenelement-different-origin.html
http/tests/navigation/keyboard-events-during-provisional-subframe-navigation.html
http/tests/pointer-lock/iframe-sandboxed-nested-allow-pointer-lock.html
http/tests/storageAccess/aggregate-sorted-data-with-storage-access.html
http/tests/storageAccess/deny-without-prompt-preserves-gesture.html
http/tests/storageAccess/request-and-grant-access-cross-origin-non-sandboxed-iframe-ephemeral.html
http/tests/storageAccess/request-and-grant-access-cross-origin-non-sandboxed-iframe.html
http/tests/storageAccess/request-and-grant-access-then-navigate-same-site-should-have-access.html
http/tests/storageAccess/request-and-grant-access-with-per-page-scope-access-from-another-frame.html
imported/blink/fast/events/click-focus-keydown-no-ring.html
imported/w3c/web-platform-tests/css/css-contain/content-visibility/content-visibility-047.html
imported/w3c/web-platform-tests/css/css-scroll-snap/input/keyboard.html
imported/w3c/web-platform-tests/css/selectors/focus-visible-008.html
imported/w3c/web-platform-tests/html/interaction/focus/focus-keyboard-js.html
imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/maxlength-number.html
imported/w3c/web-platform-tests/shadow-dom/focus/focus-tabindex-order-shadow-negative-delegatesFocus.html
imported/w3c/web-platform-tests/shadow-dom/focus/focus-tabindex-order-shadow-negative.html
platform/mac/fast/events/non-roman-key-code.html
pointer-lock/lock-element-not-in-dom.html
scrollbars/scrollbar-miss-mousemove-disabled.html
svg/custom/focus-event-handling-keyboard.xhtml
tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-horizontal-with-keyboard-scaled.html
webaudio/audiocontext-restriction-audiobuffersourcenode-start.html

How to find list of tests:

$ cd OpenSource/LayoutTests
$ $ for F in `grep -l -r &apos;KeyboardScrollingAnimator.cpp:303:10&apos; ../WebKitBuild/layout-test-results/ | sed -e &apos;s#^.*//##&apos; -e &apos;s/-stderr.txt/*/&apos;`; do ls $F | grep -v &apos;expected&apos;; done | sort | pbcopy</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1782746</commentid>
    <comment_count>1</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2021-08-07 18:48:33 -0700</bug_when>
    <thetext>Regressed in r280492 for Bug 228009.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1782747</commentid>
    <comment_count>2</comment_count>
      <attachid>435140</attachid>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2021-08-07 18:54:03 -0700</bug_when>
    <thetext>Created attachment 435140
Patch v1</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1782748</commentid>
    <comment_count>3</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2021-08-07 18:55:16 -0700</bug_when>
    <thetext>&lt;rdar://problem/81660796&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1782751</commentid>
    <comment_count>4</comment_count>
      <attachid>435140</attachid>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2021-08-07 20:28:32 -0700</bug_when>
    <thetext>Comment on attachment 435140
Patch v1

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

&gt; Source/WebCore/platform/KeyboardScrollingAnimator.h:54
&gt; +    bool m_scrollTriggeringKeyIsPressed { false };

Is there a bug here, or just another false positive that we trade a little bit of perf for?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1782752</commentid>
    <comment_count>5</comment_count>
      <attachid>435140</attachid>
    <who name="Tim Horton">thorton</who>
    <bug_when>2021-08-07 20:37:43 -0700</bug_when>
    <thetext>Comment on attachment 435140
Patch v1

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

&gt;&gt; Source/WebCore/platform/KeyboardScrollingAnimator.h:54
&gt;&gt; +    bool m_scrollTriggeringKeyIsPressed { false };
&gt; 
&gt; Is there a bug here, or just another false positive that we trade a little bit of perf for?

I think this one is legit; we read the bit in beginKeyboardScrollGesture, which is before it&apos;s set for the first time</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1782753</commentid>
    <comment_count>6</comment_count>
    <who name="Tim Horton">thorton</who>
    <bug_when>2021-08-07 20:38:46 -0700</bug_when>
    <thetext>(also this is all really really new and off-by default code, so it&apos;s not super surprising that there are bugs)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1782755</commentid>
    <comment_count>7</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2021-08-07 20:51:00 -0700</bug_when>
    <thetext>(In reply to Tim Horton from comment #5)
&gt; Comment on attachment 435140 [details]
&gt; Patch v1
&gt; 
&gt; View in context:
&gt; https://bugs.webkit.org/attachment.cgi?id=435140&amp;action=review
&gt; 
&gt; &gt;&gt; Source/WebCore/platform/KeyboardScrollingAnimator.h:54
&gt; &gt;&gt; +    bool m_scrollTriggeringKeyIsPressed { false };
&gt; &gt; 
&gt; &gt; Is there a bug here, or just another false positive that we trade a little bit of perf for?
&gt; 
&gt; I think this one is legit; we read the bit in beginKeyboardScrollGesture,
&gt; which is before it&apos;s set for the first time

What Tim said.  Here are a list of invalid values when I ran layout tests locally:

   6 platform/KeyboardScrollingAnimator.cpp:303:10: runtime error: load of value 115, which is not a valid value for type &apos;bool&apos;
   4 platform/KeyboardScrollingAnimator.cpp:303:10: runtime error: load of value 32, which is not a valid value for type &apos;bool&apos;
   3 platform/KeyboardScrollingAnimator.cpp:303:10: runtime error: load of value 6, which is not a valid value for type &apos;bool&apos;
   3 platform/KeyboardScrollingAnimator.cpp:303:10: runtime error: load of value 116, which is not a valid value for type &apos;bool&apos;
   2 platform/KeyboardScrollingAnimator.cpp:303:10: runtime error: load of value 97, which is not a valid value for type &apos;bool&apos;
   2 platform/KeyboardScrollingAnimator.cpp:303:10: runtime error: load of value 108, which is not a valid value for type &apos;bool&apos;
   1 platform/KeyboardScrollingAnimator.cpp:303:10: runtime error: load of value 98, which is not a valid value for type &apos;bool&apos;
   1 platform/KeyboardScrollingAnimator.cpp:303:10: runtime error: load of value 84, which is not a valid value for type &apos;bool&apos;
   1 platform/KeyboardScrollingAnimator.cpp:303:10: runtime error: load of value 59, which is not a valid value for type &apos;bool&apos;
   1 platform/KeyboardScrollingAnimator.cpp:303:10: runtime error: load of value 49, which is not a valid value for type &apos;bool&apos;
   1 platform/KeyboardScrollingAnimator.cpp:303:10: runtime error: load of value 40, which is not a valid value for type &apos;bool&apos;
   1 platform/KeyboardScrollingAnimator.cpp:303:10: runtime error: load of value 4, which is not a valid value for type &apos;bool&apos;
   1 platform/KeyboardScrollingAnimator.cpp:303:10: runtime error: load of value 24, which is not a valid value for type &apos;bool&apos;
   1 platform/KeyboardScrollingAnimator.cpp:303:10: runtime error: load of value 111, which is not a valid value for type &apos;bool&apos;
   1 platform/KeyboardScrollingAnimator.cpp:303:10: runtime error: load of value 104, which is not a valid value for type &apos;bool&apos;
   1 platform/KeyboardScrollingAnimator.cpp:303:10: runtime error: load of value 101, which is not a valid value for type &apos;bool&apos;
   1 platform/KeyboardScrollingAnimator.cpp:303:10: runtime error: load of value 100, which is not a valid value for type &apos;bool&apos;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1782758</commentid>
    <comment_count>8</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2021-08-07 21:18:06 -0700</bug_when>
    <thetext>Committed r280764 (240349@main): &lt;https://commits.webkit.org/240349@main&gt;

All reviewed patches have been landed. Closing bug and clearing flags on attachment 435140.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>435140</attachid>
            <date>2021-08-07 18:54:03 -0700</date>
            <delta_ts>2021-08-07 21:18:07 -0700</delta_ts>
            <desc>Patch v1</desc>
            <filename>bug-228901-20210807185402.patch</filename>
            <type>text/plain</type>
            <size>1530</size>
            <attacher name="David Kilzer (:ddkilzer)">ddkilzer</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjgwNzYwCmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViQ29yZS9D
aGFuZ2VMb2cgYi9Tb3VyY2UvV2ViQ29yZS9DaGFuZ2VMb2cKaW5kZXggOGRiNmE2MWFkZTBlMmZj
MDE1ZTY2ZjYwZjlhZDU2N2I4ODlkZjE0Zi4uZjQ5NmYwNWMxNDMwOGViZDAwYzE5Y2Y2YWI1YjM1
YzQ5OWZkZDEyZSAxMDA2NDQKLS0tIGEvU291cmNlL1dlYkNvcmUvQ2hhbmdlTG9nCisrKyBiL1Nv
dXJjZS9XZWJDb3JlL0NoYW5nZUxvZwpAQCAtMSwzICsxLDE1IEBACisyMDIxLTA4LTA3ICBEYXZp
ZCBLaWx6ZXIgIDxkZGtpbHplckBhcHBsZS5jb20+CisKKyAgICAgICAgVUJTYW46IEtleWJvYXJk
U2Nyb2xsaW5nQW5pbWF0b3IuY3BwOjMwMzoxMDogcnVudGltZSBlcnJvcjogbG9hZCBvZiB2YWx1
ZSBubm4sIHdoaWNoIGlzIG5vdCBhIHZhbGlkIHZhbHVlIGZvciB0eXBlICdib29sJworICAgICAg
ICA8aHR0cHM6Ly93ZWJraXQub3JnL2IvMjI4OTAxPgorCisgICAgICAgIFJldmlld2VkIGJ5IE5P
Qk9EWSAoT09QUyEpLgorCisgICAgICAgIENvdmVyZWQgYnkgcnVubmluZyA3OCBsYXlvdXQgdGVz
dHMgd2l0aCBVQlNhbiBlbmFibGVkLgorCisgICAgICAgICogcGxhdGZvc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