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

crash related to mouse on OSX (null pointer)

    XMLWordPrintable

Details

    • macOS
    • 28f689271737d98a23c18b5be2f7f8e1988c1268 (qt/qtbase/dev) 0de0c21b2f95beba95d265647a8e5d25faddcdb9 (qt/qtbase/5.15)

    Description

      After changing from Qt 5.13.0 to 5.13.1, some users started to experiment a mouse-related crash.
      See stack trace further.
      Although hard to reproduce, I could finally produce once the crash under the debugger.
      It seems to be an event race condition.

      The crash happens because m_platformWindow is null and accessed at some point.
      (in my case, in (void)mouseDown:(NSEvent *)theEvent)

      In qnsview_mouse.mm, most of the functions accessing m_platformWindow starts with:

          if (!m_platformWindow)
              return;
      

      But not two of them, and of course the crash happens in one of them.
      Therefore I have added these:

      1)

      - (bool)handleMouseDownEvent:(NSEvent *)theEvent
      {
          if (!m_platformWindow)
              return false;
      

      2)

      - (void)mouseDown:(NSEvent *)theEvent
      {
          if ([self isTransparentForUserInput])
              return [super mouseDown:theEvent];
      
          if (!m_platformWindow)
              return;
      

      3) further in the mouseDown function, there is a call to

      QWindowSystemInterface::flushWindowSystemEvents();

      This could have any side effect, including setting 'm_platformWindow' to null (and that might be the core cause)
      Hence after this code section, I have added another:

          if (!m_platformWindow)
              return;
      

      and I could not reproduce the problem so far.

      About the context. It seems that the problem happens when tooltip are involved.
      That is, the mouse is used to do some actions, and some tooltip appear and disappear quickly
      cf. my remark about flushWindowSystemEvents. and BTW, this is surprising that this call does not have as argument QEventLoop::ExcludeUserInputEvents

      This is the stack trace when the problem occurs:

      Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
      0   org.qt-project.QtGui          	0x000000010c0f2674 QPlatformWindow::window() const + 4
      1   libqcocoa.dylib               	0x000000010f20af60 -[QNSView(Mouse) mouseDown:] + 928
      2   com.apple.AppKit              	0x00007fff3d447937 -[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:] + 5724
      3   com.apple.AppKit              	0x00007fff3d37e1a6 -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 2295
      4   com.apple.AppKit              	0x00007fff3d37d667 -[NSWindow(NSEventRouting) sendEvent:] + 478
      5   libqcocoa.dylib               	0x000000010f215521 -[QNSPanel sendEvent:] + 561
      6   com.apple.AppKit              	0x00007fff3d21ce6b -[NSApplication(NSEvent) sendEvent:] + 331
      7   libqcocoa.dylib               	0x000000010f21b55a -[QNSApplication sendEvent:] + 74
      8   com.apple.AppKit              	0x00007fff3d20b5e0 -[NSApplication run] + 755
      9   libqcocoa.dylib               	0x000000010f2187a0 QCocoaEventDispatcher::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 2656
      10  org.qt-project.QtCore         	0x000000010b318e7e QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 462
      11  org.qt-project.QtCore         	0x000000010b321232 QCoreApplication::exec() + 130
      

      Attachments

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

        Activity

          People

            vestbo Tor Arne Vestbø
            jirauser26727 user-04d21 (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes