Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / qt / 2007-10

Random crashes on Mac with the magnifier

6 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Felipe Monteiro de Carvalho

Hello,

I am getting some almost random crashes when using the magnifier with Qt on Mac. One case is when changing the translation. The user will click a menu item on the systemtray icon and that will cause the menu to be destroyed and recreated with the new strings. Always worked on Win32 and Gtk2.

The worse is that the backtrace shows nothing useful. It doesn't crash in my code, but inside Qt after my code was executed... and it only crashes some times. Some times I can do this operation many times until it finally crashes.

Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_PROTECTION_FAILURE at address: 0x00000037 0x01cd9ef0 in QMetaObject::activate ()
(gdb) bt
#0 0x01cd9ef0 in QMetaObject::activate ()
#1 0x0215002f in QMenu::triggered ()
#2 0x01e1b976 in -[QNSMenu selectedAction:] ()
#3 0x93380d88 in -[NSApplication sendAction:to:from:] () #4 0x9342ece7 in -[NSMenu performActionForItemAtIndex:] () #5 0x9342ea29 in -[NSCarbonMenuImpl
performActionWithHighlightingForItemAtIndex:] ()
#6 0x93437059 in _NSPopUpCarbonMenu2 ()
#7 0x93436202 in _NSPopUpCarbonMenu1 ()
#8 0x936d67fb in -[NSStatusItem(NSStatusItemCommon) popUpStatusItemMenu:] () #9 0x01e1b0f2 in -[QNSStatusItem triggerSelector:] () #10 0x01e1ba9c in -[QNSImageView mouseDown:] ()
#11 0x933703af in -[NSWindow sendEvent:] ()
#12 0x9358ac94 in carbonAppWindowMouseHandler ()
#13 0x92dec537 in DispatchEventToHandlers ()
#14 0x92debbdc in SendEventToEventTargetInternal () #15 0x92df2fbc in SendEventToEventTarget ()
#16 0x92df344f in ToolboxEventDispatcherHandler () #17 0x92dec8ee in DispatchEventToHandlers ()
#18 0x92debbdc in SendEventToEventTargetInternal () #19 0x92df2fbc in SendEventToEventTarget ()
#20 0x01e68586 in qt_mac_send_event ()
#21 0x01e757d2 in QEventDispatcherMac::processEvents () #22 0x01cc9feb in QCoreApplication::processEvents () #23 0x01a06fa1 in QCoreApplication_processEvents () #24 0x001534d1 in TQTWIDGETSET__APPWAITMESSAGE (this=0xeea0c0) at qtobject.inc:145
#25 0x0002efcc in TAPPLICATION__IDLE (WAIT=true, this=0xf32020) at application.inc:312
#26 0x0003040f in TAPPLICATION__HANDLEMESSAGE (this=0xf32020) at application.inc:944
#27 0x00030804 in RUNMESSAGE (parentfp=0xbffff568) at application.inc:1057 #28 0x0003075d in TAPPLICATION__RUNLOOP (this=0xf32020) at application.inc:1067 #29 0x001534a3 in TQTWIDGETSET__APPRUN (ALOOP=0x30720 <TAPPLICATION__RUNLOOP>, this=0xeea0c0) at qtobject.inc:127 #30 0x0003071a in TAPPLICATION__RUN (this=0xf32020) at application.inc:1046 #31 0x00002153 in PASCALMAIN () at magnifier.dpr:135 #32 0x000181c0 in SYSTEM_FPC_SYSTEMMAIN$LONGINT$PPCHAR$PPCHAR () #33 0x00002062 in _start ()
#34 0x00001f89 in start ()

Here is the method being executed when clicking the menu:

procedure TMainWindow.Translate(Sender: TObject);
begin
  if (Sender is TMenuItem) then
  begin
    case (Sender as TMenuItem).MenuIndex of
     ID_MENU_SPANISH: vTranslations.TranslateToSpanish;
     ID_MENU_ENGLISH: vTranslations.TranslateToEnglish;
     ID_MENU_PORTUGUESE: vTranslations.TranslateToPortuguese;
     ID_MENU_FRENCH: vTranslations.TranslateToFrench;
     ID_MENU_GERMAN: vTranslations.TranslateToGerman;
     ID_MENU_ITALIAN: vTranslations.TranslateToItalian;
     ID_MENU_RUSSIAN: vTranslations.TranslateToRussian;
     ID_MENU_POLISH: vTranslations.TranslateToPolish;
    else
      Exit; // Error
    end;
    vTranslations.UpdateTranslations;
    vConfigurations.Language := (Sender as TMenuItem).MenuIndex;
  end;
  vMenu.Free;
  Application.ProcessMessages;
  vMenu := TPopupMenu.Create(Self);
  CreateTaskbarMenu(vMenu);
end;

The Lazarus debuger shows the error here:

procedure TQtWidgetSet.AppWaitMessage;
begin
  {we cannot call directly processEvents() with this flag
   since it produces AV's sometimes, so better check is there
   any pending event.}
  if not QCoreApplication_hasPendingEvents then
    QCoreApplication_processEvents(QEventLoopWaitForMoreEvents);
end;

And it doesn't crash just here. It also crashes if I press the arrow keys while running the glass, which just sets some variables and does nothing complex. Again, not inside my code but while waiting for more events...

Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_INVALID_ADDRESS at address: 0x3b333132 0x01e5731c in QWidget::actions ()
(gdb) bt
#0 0x01e5731c in QWidget::actions ()
#1 0x01e1bd35 in -[QNSMenu menuNeedsUpdate:] ()
#2 0x9336e1c0 in -[NSMenu _populate:] ()
#3 0x9336e0d7 in AppKitMenuEventHandler ()
#4 0x92dec537 in DispatchEventToHandlers ()
#5 0x92debbdc in SendEventToEventTargetInternal () #6 0x92debaa1 in SendEventToEventTargetWithOptions () #7 0x92e8fbc7 in SendMenuPopulate ()
#8 0x92eaaec2 in PopulateMenu ()
#9 0x92eaa591 in Check1MenuForKeyEvent ()
#10 0x92ecb51c in CheckEachHMenuForKeyEvent ()
#11 0x92e27e77 in ForEachInstalledHMenuDo ()
#12 0x92eaa011 in CheckMenusForKeyEvent ()
#13 0x92ea9cc4 in _IsMenuKeyEvent ()
#14 0x92ea9a0d in IsMenuKeyEvent ()
#15 0x92ec67fb in CompatibilityMenuBarEventHandler () #16 0x92dec537 in DispatchEventToHandlers ()
#17 0x92debbdc in SendEventToEventTargetInternal () #18 0x92debaa1 in SendEventToEventTargetWithOptions () #19 0x92df3600 in ToolboxEventDispatcherHandler () #20 0x92dec8ee in DispatchEventToHandlers ()
#21 0x92debbdc in SendEventToEventTargetInternal () #22 0x92df2fbc in SendEventToEventTarget ()
#23 0x01e68586 in qt_mac_send_event ()
#24 0x01e757d2 in QEventDispatcherMac::processEvents () #25 0x01cc9feb in QCoreApplication::processEvents () #26 0x01a06fa1 in QCoreApplication_processEvents () #27 0x001534d1 in TQTWIDGETSET__APPWAITMESSAGE (this=0xeea0c0) at qtobject.inc:145
#28 0x0002efcc in TAPPLICATION__IDLE (WAIT=true, this=0xf32020) at application.inc:312
#29 0x0003040f in TAPPLICATION__HANDLEMESSAGE (this=0xf32020) at application.inc:944
#30 0x00030804 in RUNMESSAGE (parentfp=0xbffff568) at application.inc:1057 #31 0x0003075d in TAPPLICATION__RUNLOOP (this=0xf32020) at application.inc:1067 #32 0x001534a3 in TQTWIDGETSET__APPRUN (ALOOP=0x30720 <TAPPLICATION__RUNLOOP>, this=0xeea0c0) at qtobject.inc:127 #33 0x0003071a in TAPPLICATION__RUN (this=0xf32020) at application.inc:1046 #34 0x00002153 in PASCALMAIN () at magnifier.dpr:135 #35 0x000181c0 in SYSTEM_FPC_SYSTEMMAIN$LONGINT$PPCHAR$PPCHAR () #36 0x00002062 in _start ()
#37 0x00001f89 in start ()

I don't remember this problems before, but maybe I just didn't test it enougth. I went up to revision 12200 but they still happen there.

Any ideas?

thanks,

Felipe Monteiro de Carvalho

Reply by email

Paul Ishenin
to Felipe Monteiro de Carvalho

Felipe Monteiro de Carvalho ?????:

[skip many words]

I don't remember this problems before, but maybe I just didn't test it enougth. I went up to revision 12200 but they still happen there. Any ideas?

Once I looked at qt source to understand how qt loop differ from lcl loop. And seems qt uses processEvents always with
QEventLoopDeferredDeletion flag. You can try to change all QCoreApplication_processEvents and pass there that flag with 'or' (same as TQtWidgetSet.AppProcessMessages done).

Best regards,
Paul Ishenin.

Reply by email