2
votes

After moving a Delphi 2009 application from a Windows 2003 / Citrix environment to a 64 bit Windows 2008 R2 environment (users now use RDP instead of Citrix), there are now runtime errors saying "Cannot make a visible Window modal".

The user opens a modal form. Then somehow an event handler which is assigned to a menu item in the main form is triggered. Based on the call stacks, it looks like the user is able to invoke the menu item by pressing its shortcut.

The madExcept stack trace looks like this:

main thread ($2dc):
004ffa88 +06c Ladelist.exe Forms            TCustomForm.ShowModal
0052f4ff +0bb Ladelist.exe DB               TDataSet.SetActive
008fc9a1 +089 Ladelist.exe u_ladeli 928 +16 TForm1.EditLoadingList
008fadec +070 Ladelist.exe u_ladeli 504  +5 TForm1.OpenLoadingListClick <- second
004d6e27 +0a7 Ladelist.exe Menus            TMenuItem.Click
004d857f +0ef Ladelist.exe Menus            DoClick
004d866b +087 Ladelist.exe Menus            TMenu.IsShortCut
005001c1 +04d Ladelist.exe Forms            TCustomForm.IsShortCut
004e8dc0 +068 Ladelist.exe Controls         TWinControl.IsMenuKey
004e8f89 +011 Ladelist.exe Controls         TWinControl.CNSysKeyDown
004e247e +2d2 Ladelist.exe Controls         TControl.WndProc
004e6983 +513 Ladelist.exe Controls         TWinControl.WndProc
004fb5e8 +594 Ladelist.exe Forms            TCustomForm.WndProc
004e20a4 +024 Ladelist.exe Controls         TControl.Perform
004856e0 +014 Ladelist.exe Classes          StdWndProc
004e609c +02c Ladelist.exe Controls         TWinControl.MainWndProc
004856e0 +014 Ladelist.exe Classes          StdWndProc
775b00e3 +02b ntdll.dll                     KiUserCallbackDispatcher
008fc9a1 +089 Ladelist.exe u_ladeli 928 +16 TForm1.EditLoadingList
008fadec +070 Ladelist.exe u_ladeli 504  +5 TForm1.OpenLoadingListClick <- first
004d6e27 +0a7 Ladelist.exe Menus            TMenuItem.Click
004d857f +0ef Ladelist.exe Menus            DoClick
004d866b +087 Ladelist.exe Menus            TMenu.IsShortCut
005001c1 +04d Ladelist.exe Forms            TCustomForm.IsShortCut
004e8dc0 +068 Ladelist.exe Controls         TWinControl.IsMenuKey
004e8e0d +01d Ladelist.exe Controls         TWinControl.CNKeyDown
004e247e +2d2 Ladelist.exe Controls         TControl.WndProc
004e6983 +513 Ladelist.exe Controls         TWinControl.WndProc
004fb5e8 +594 Ladelist.exe Forms            TCustomForm.WndProc
004e20a4 +024 Ladelist.exe Controls         TControl.Perform
004e609c +02c Ladelist.exe Controls         TWinControl.MainWndProc
004856e0 +014 Ladelist.exe Classes          StdWndProc
775b00e3 +02b ntdll.dll                     KiUserCallbackDispatcher
753c3675 +010 kernel32.dll                  BaseThreadInitThunk

Second example:

main thread ($4c94):
004ffa88 +06c Ladelist.exe Forms                    TCustomForm.ShowModal
0052f4ff +0bb Ladelist.exe DB                       TDataSet.SetActive
008fc9a1 +089 Ladelist.exe u_ladeli         928 +16 TForm1.EditLoadingList
008fbacd +085 Ladelist.exe u_ladeli         765 +11 TForm1.SearchShipmentClick
004d6e27 +0a7 Ladelist.exe Menus                    TMenuItem.Click
004d857f +0ef Ladelist.exe Menus                    DoClick
004d866b +087 Ladelist.exe Menus                    TMenu.IsShortCut
005001c1 +04d Ladelist.exe Forms                    TCustomForm.IsShortCut
004e8dc0 +068 Ladelist.exe Controls                 TWinControl.IsMenuKey
004e8f89 +011 Ladelist.exe Controls                 TWinControl.CNSysKeyDown
004e247e +2d2 Ladelist.exe Controls                 TControl.WndProc
004e6983 +513 Ladelist.exe Controls                 TWinControl.WndProc
004fb5e8 +594 Ladelist.exe Forms                    TCustomForm.WndProc
004e20a4 +024 Ladelist.exe Controls                 TControl.Perform
004856e0 +014 Ladelist.exe Classes                  StdWndProc
004e609c +02c Ladelist.exe Controls                 TWinControl.MainWndProc
004856e0 +014 Ladelist.exe Classes                  StdWndProc
772b00e3 +02b ntdll.dll                             KiUserCallbackDispatcher
008fc9a1 +089 Ladelist.exe u_ladeli         928 +16 TForm1.EditLoadingList
008fadec +070 Ladelist.exe u_ladeli         504  +5 TForm1.OpenLoadingListClick
004d6e27 +0a7 Ladelist.exe Menus                    TMenuItem.Click
004d857f +0ef Ladelist.exe Menus                    DoClick
004d866b +087 Ladelist.exe Menus                    TMenu.IsShortCut
005001c1 +04d Ladelist.exe Forms                    TCustomForm.IsShortCut
004e8dc0 +068 Ladelist.exe Controls                 TWinControl.IsMenuKey
004e8e0d +01d Ladelist.exe Controls                 TWinControl.CNKeyDown
0067ead1 +03d Ladelist.exe cxControls               TcxControl.CNKeyDown
007b2351 +019 Ladelist.exe cxGridCustomView         TcxGridSite.CNKeyDown
004e247e +2d2 Ladelist.exe Controls                 TControl.WndProc
004e885c +01c Ladelist.exe Controls                 TWinControl.WMNCHitTest
004e247e +2d2 Ladelist.exe Controls                 TControl.WndProc
004e6983 +513 Ladelist.exe Controls                 TWinControl.WndProc
0067ef6c +11c Ladelist.exe cxControls               TcxControl.WndProc
007b2b1f +01b Ladelist.exe cxGridCustomView         TcxGridSite.WndProc
004e609c +02c Ladelist.exe Controls                 TWinControl.MainWndProc
004856e0 +014 Ladelist.exe Classes                  StdWndProc
772b00e3 +02b ntdll.dll                             KiUserCallbackDispatcher
76973675 +010 kernel32.dll                          BaseThreadInitThunk

Update:

Windows Server 2008 R2 Service Pack 1 is now installed. But the same strange errors occur. We also frequently have these errors:

exception class   : EAccessViolation
exception message : Zugriffsverletzung bei Adresse 5E9E19ED in Modul 'audiodev.dll'. Schreiben von Adresse 5E9E19ED.

thread $3068:
5e9e19ed +00 audiodev.dll
0045146d +0d PDFView.exe  madExcept CallThreadProcSafe
00451b77 +37 PDFView.exe  madExcept UserWorkItemExceptFrame
75543398 +10 kernel32.dll           BaseThreadInitThunk

and

exception class   : EAccessViolation
exception message : Zugriffsverletzung bei Adresse 74DC1E3D in Modul 'wkscli.dll'. Schreiben von Adresse 74DC1E3D.

thread $1eb8:
74dc1e3d +000 wkscli.dll
758e0165 +160 RPCRT4.dll             NdrClientCall2
74dc2dce +032 wkscli.dll             NetWkstaGetInfo
6a142162 +007 ntlanman.dll           NPOpenEnum
6a1a2f9a +094 MPR.dll                WNetOpenEnumW
0045146d +00d PDFView.exe  madExcept CallThreadProcSafe
00451b77 +037 PDFView.exe  madExcept UserWorkItemExceptFrame
77193398 +010 kernel32.dll           BaseThreadInitThunk

and

exception message : Zugriffsverletzung bei Adresse 70841F8E in Modul 'olmapi32.dll'. Schreiben von Adresse 70841F8E.

main thread ($5978):
70841f8e +000 ???
005cade0 +654 PDFView.exe  JclMapi      65 +0 TJclEmail.InternalSendOrSave
005cb140 +004 PDFView.exe  JclMapi      65 +0 TJclEmail.Send

and

exception class : EAccessViolation exception message : Zugriffsverletzung bei Adresse 565014FD in Modul 'wpdshext.dll'. Schreiben von Adresse 565014FD.

thread $3960: 565014fd +00 wpdshext.dll 76efc511 +4c SHLWAPI.dll QISearch 0045146d +0d PDFView.exe madExcept CallThreadProcSafe 00451b77 +37 PDFView.exe madExcept UserWorkItemExceptFrame 77193398 +10 kernel32.dll BaseThreadInitThunk

It looks like these are related to the usage of an Acrobat (version X) ActiveX control in this application so I'll investigate in this direction. The errors in the original problem report above however appears in an application which does not use Acrobat.

1
@mjn - does this happen only with keyboard input or with mouse input to? Is it reproducable with a small test application? - Lieven Keersmaekers
@Lieven I am waiting for user feedback but looking at the code I think the user somehow is able to invoke the menu item shortcut from within the modal form - mjn
@mjn: Could it be that the user was actually able to invoke the shortcut twice before the form appeared? I encountered a similar problem that had to do with button clicks instead of menu item shortcuts, and that was in a Citrix environment actually, not in RDP. - Andriy M
Are there any Application.ProcessMessages? That could give the user the brake it needs to invoke the shortcut again! - Cosmin Prund
@David - calls to ProcessMessages are NOT fine. NOT one little bit fine. The message loop in ShowModal is different - it provides a message pump that is required to continue pumping messages until the modal dialog is dismissed. But calling ProcessMessages in the middle of an event handler means that that event handler could itself be re-entered while it is still handling some initial event. Re-entrancy in code that is not designed for re-entrancy is FAR from "fine". - Deltics

1 Answers

1
votes

Oh!! I just had this problem with windows 2008. It found out it was a Windows issue, that is well reported by other users around the world. Microsoft has release some fixes, but none of them worked as expected. Finally, Microsoft released SP1 and now it works as a charm.

So, install the Windows 2008 R2 SP1 Windows 2008 R2 bug fixes