Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-82355

[REG 5.12->5.14] QScroller memory leak regression

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P1: Critical
    • None
    • 5.14.0
    • None
    • linux/amd64/x11
    • Linux/X11

    Description

      I build qt 5.14 with:

      ./configure -v -opensource -developer-build -confirm-license -nomake tests -nomake examples -sanitize address -sanitize undefined -prefix /usr/local/qt5_debug -qt-libjpeg -qt-zlib -qt-libpng -use-gold-linker -recheck-all
      

      If I run

      #include <QApplication>
      #include <QLabel>
      #include <QScroller>
      
      static void my_kinetic_scroll_for_widget(QWidget &view)
      {
          auto scroller = QScroller::scroller(&view);
          assert(scroller != nullptr);
          assert(scroller->target() == &view);
      
          QScrollerProperties properties = QScroller::scroller(scroller)->scrollerProperties();
          QVariant overshootPolicy = QVariant::fromValue<QScrollerProperties::OvershootPolicy>(
              QScrollerProperties::OvershootAlwaysOff);
          properties.setScrollMetric(QScrollerProperties::VerticalOvershootPolicy,
                                     overshootPolicy);
          scroller->setScrollerProperties(properties);
          properties.setScrollMetric(QScrollerProperties::HorizontalOvershootPolicy,
                                     overshootPolicy);
          scroller->setScrollerProperties(properties);
          // Scrolling Gesture
          if (qApp->property("use-touchscreen").toBool()) {
              scroller->grabGesture(&view, QScroller::TouchGesture);
          }
          else {
              scroller->grabGesture(&view, QScroller::LeftMouseButtonGesture);
          }
      }
      
      int main(int argc, char *argv[])
      {
          QApplication app{ argc, argv };
          QLabel lbl;
          my_kinetic_scroll_for_widget(lbl);
          lbl.resize(400, 400);
          lbl.show();
      
          return app.exec();
      }
      

      I got:
      ```
      Direct leak of 16 byte(s) in 1 object(s) allocated from:
      #0 0x7f5679e5a968 in operator new(unsigned long) /build/gcc/src/gcc/libsanitizer/asan/asan_new_delete.cc:104
      #1 0x7f566e4606fc in QScroller::grabGesture(QObject*, QScroller::ScrollerGestureType) util/qscroller.cpp:419
      #2 0x560a5bab8384 in my_kinetic_scroll_for_widget main.cpp:25
      #3 0x560a5bab8384 in main.cpp:33
      #4 0x7f565243d022 in __libc_start_main (/usr/lib/libc.so.6+0x27022)
      ```

      In other words there is memory leak here:

       scroller->grabGesture(&view, QScroller::LeftMouseButtonGesture);
      

      There is no such issue in previous version (I am not sure what version I use before, I suppose 5.12).

      If I revert this patch:

      commit 7d73d4b9a93b3132c1a24aa3ae77f0a307e821fd
      Author: Andy Shaw <andy.shaw@qt.io>
      Date:   Tue Aug 20 10:53:53 2019 +0200
      
          Remove the unregistered recognizer from the main list
          
          This amends 1320b2f64412f0d86bd09c66c22df845e13a94a1 to keep the
          behavior of removing from the main list but without re-introducing the
          memory leak.
          
          Fixes: QTBUG-77770
          Change-Id: I91fa6cb71fab8d60baa35417fdb34322af11dbbb
          Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
          Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
      
      

      asan stops report memory leak, so I suppose Qt version before that commit
      is not affected by this issue.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            evgeniy_dushistov evgeniy_dushistov
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes