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

Serious Memory leak in qaccessible_mac.mm QAElement::QAElement under Mac OSX (valgrind is out for Mac OSX)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P0: Blocker
    • 4.7.1
    • 4.5.1, 4.5.2, 4.5.3
    • None
    • macOS
    • 8325c15b21cd49287160c8dfb31ebf56ba3090ab

    Description

      valgrind 3.5.0 for Mac OSX reports the following when running the examples/widgets/lineedits (run the app with
      % DYLD_IMAGE_SUFFIX=_debug valgrind --dsymutil=yes --leak-check=full ./lineedits.app/Contents/MacOS/lineedits >report.log 2>&1
      type a number into each lineedit and quit the app
      )
      one of the lost blocks look like that

      ==57464== 1,280 (512 direct, 768 indirect) bytes in 16 blocks are definitely lost in loss record 3,375 of 3,503
      ==57464==    at 0x1D4CA: malloc_zone_malloc (vg_replace_malloc.c:199)
      ==57464==    by 0x325A200: _CFRuntimeCreateInstance (in /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation)
      ==57464==    by 0x57FA730: _AXUIElementCreateInternal (in /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/HIServices.framework/Versions/A/HIServices)
      ==57464==    by 0x57FA6E2: _AXUIElementCreateWithData (in /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/HIServices.framework/Versions/A/HIServices)
      ==57464==    by 0x381F6D7: AXUIElementCreateWithHIObjectAndData (in /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox)
      ==57464==    by 0x381F66F: AXUIElementCreateWithHIObjectAndIdentifier (in /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox)
      ==57464==    by 0x10AD0E4: QAElement::QAElement(OpaqueHIObjectRef*, int) (qaccessible_mac.mm:511)
      ==57464==    by 0x10B4F96: QStandardInterfaceFactory::element(int) (qaccessible_mac.mm:839)
      ==57464==    by 0x10AEC6E: QAccessibleHierarchyManager::lookup(QObject*, int) (qaccessible_mac.mm:808)
      ==57464==    by 0x10B3877: QAccessible::updateAccessibility(QObject*, int, QAccessible::Event) (qaccessible_mac.mm:2410)
      ==57464==    by 0x112FBDC: QWidgetPrivate::show_helper() (qwidget.cpp:6778)
      ==57464==    by 0x11301E2: QWidget::setVisible(bool) (qwidget.cpp:6980)
      

      By looking into the call tree its obvious that QAElement::QAElement is the cause:
      the call to AXUIElementCreateWithHIObjectAndIdentifier() is done twice to initialize the 'elementRef' member. The same code section in qt4.4.3 didn't do that,
      apparently the bug was created during the move to Cocoa

      QAElement::QAElement(HIObjectRef object, int child)
          :elementRef(
      #ifndef QT_MAC_USE_COCOA
                      AXUIElementCreateWithHIObjectAndIdentifier(object, child)
      #endif
      )
      {
      #ifndef QT_MAC_USE_COCOA
          if (object == 0) {
              elementRef = 0; // Create invalid QAElement.
          } else {
              elementRef = AXUIElementCreateWithHIObjectAndIdentifier(object, child);
              CFRetain(object);
          }
      #else
          Q_UNUSED(object);
          Q_UNUSED(child);
      #endif
      }
      

      If I comment the 1st initialization of 'elementRef'

      QAElement::QAElement(HIObjectRef object, int child)
      //    :elementRef(
      //#ifndef QT_MAC_USE_COCOA
      //                AXUIElementCreateWithHIObjectAndIdentifier(object, child)
      //#endif
      //)
      

      then this place doesn't appear anymore in the sample, the program works and only has 248 definitely lost bytes in comparison to 2.812 bytes with the current release
      Kind Regards, Leo

      Attachments

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

        Activity

          People

            sorvig Morten Sørvig
            ls@4js.com Leo Schubert
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes