Strange "random" exception in a Delphi 2009 application

Posted on 2012-03-23
Medium Priority
Last Modified: 2012-04-01
In one "large" (100.000 lines of code + 3rd party libs) Delphi application, I get the following Madshi stack traceS (message in french, sorry, means access violation at address ...)
What is very strange is the following : the crashes occur when "apparently" calling function gm2000Dispatch, as the trace is not inside the function gm2000Dispatch code which, by the way, in inside the same unit U2000A

exception class   : EAccessViolation
exception message : Violation d'acc¿s ¿ l'adresse 00404B95 dans le module 'Gm2000.exe'. Lecture de l'adresse FFFFFFFE.

main thread ($898):
00404b95 +00d Gm2000.exe   System    903  +0 GetDynaMethod
00404bbc +004 Gm2000.exe   System    903  +0 @CallDynaInst
004cfd3e +012 Gm2000.exe   Controls          TControl.SetVisible
004b616e +03a Gm2000.exe   Forms             TCustomForm.SetVisible
004babc3 +007 Gm2000.exe   Forms             TCustomForm.Show
0075ba0f +0c3 Gm2000.exe   U2000A   1779  +9 gm2000Dispatch
00763009 +039 Gm2000.exe   U2000A   3426  +1 TF2000A.MenuLotInformationClick
004c5fbb +0a7 Gm2000.exe   Menus             TMenuItem.Click
004c726f +013 Gm2000.exe   Menus             TMenu.DispatchCommand
004b9917 +01f Gm2000.exe   Forms             TCustomForm.WMCommand
004d1542 +2d2 Gm2000.exe   Controls          TControl.WndProc
004d5a47 +513 Gm2000.exe   Controls          TWinControl.WndProc
004b6878 +594 Gm2000.exe   Forms             TCustomForm.WndProc
004d5160 +02c Gm2000.exe   Controls          TWinControl.MainWndProc
00485e68 +014 Gm2000.exe   Classes           StdWndProc
766b8e97 +00a USER32.dll                     DispatchMessageW
004bef8d +11d Gm2000.exe   Forms             TApplication.ProcessMessage
004befd2 +00a Gm2000.exe   Forms             TApplication.HandleMessage
004bf2fd +0c9 Gm2000.exe   Forms             TApplication.Run
00768e20 +1a4 Gm2000.exe   Gm2000    285 +30 initialization
75fe1172 +010 kernel32.dll                   BaseThreadInitThunk

Sometime, I get this (in the same user action context)
exception class   : EAccessViolation
exception message : Violation d'acc¿s ¿ l'adresse 00000000. Lecture de l'adresse 00000000.

main thread ($d8):
00000000 +000 ???
00485e68 +014 GM2000.EXE Classes           StdWndProc
004cc544 +0fc GM2000.EXE Controls          InitWndProc
7c91eae0 +010 ntdll.dll                    KiUserCallbackDispatcher
77d1ff7e +02e USER32.dll                   CreateWindowExW
0040b413 +03f GM2000.EXE Windows           CreateWindowEx
004d4884 +030 GM2000.EXE Controls          TWinControl.CreateWindowHandle
004b8844 +0fc GM2000.EXE Forms             TCustomForm.CreateWindowHandle
004d47a1 +139 GM2000.EXE Controls          TWinControl.CreateWnd
004b486d +005 GM2000.EXE Forms             TScrollingWinControl.CreateWnd
004b8556 +00a GM2000.EXE Forms             TCustomForm.CreateWnd
004d4baa +016 GM2000.EXE Controls          TWinControl.CreateHandle
004d872c +01c GM2000.EXE Controls          TWinControl.HandleNeeded
004d8739 +005 GM2000.EXE Controls          TWinControl.GetHandle
004b7354 +00c GM2000.EXE Forms             TCustomForm.GetMonitor
004b7bbc +088 GM2000.EXE Forms             TCustomForm.SetWindowToMonitor
004b6165 +031 GM2000.EXE Forms             TCustomForm.SetVisible
004babc3 +007 GM2000.EXE Forms             TCustomForm.Show
0075ba0f +0c3 GM2000.EXE U2000A   1779  +9 gm2000Dispatch
00763009 +039 GM2000.EXE U2000A   3426  +1 TF2000A.MenuLotInformationClick
004c5fbb +0a7 GM2000.EXE Menus             TMenuItem.Click
004c726f +013 GM2000.EXE Menus             TMenu.DispatchCommand
004b9917 +01f GM2000.EXE Forms             TCustomForm.WMCommand
004d1542 +2d2 GM2000.EXE Controls          TControl.WndProc
004d56ca +196 GM2000.EXE Controls          TWinControl.WndProc
004b6878 +594 GM2000.EXE Forms             TCustomForm.WndProc
004d5160 +02c GM2000.EXE Controls          TWinControl.MainWndProc
00485e68 +014 GM2000.EXE Classes           StdWndProc
77d18a0b +00a USER32.dll                   DispatchMessageW
004bef8d +11d GM2000.EXE Forms             TApplication.ProcessMessage
004befd2 +00a GM2000.EXE Forms             TApplication.HandleMessage
004bf2fd +0c9 GM2000.EXE Forms             TApplication.Run
00768e20 +1a4 GM2000.EXE Gm2000    285 +30 initialization

On another trace, I get an Abstract Error (trace not currently available)

Same user action, different crash
The problems for me to fix this are :
1. is this real that a simple function call can crash before being inside the function, as it looks to be here ?
2. I can't reproduce the problem on my development PC, neither in debug mode in the IDE, nor outside, executing the .exe

How can I find what's wrong there ?
(that application has run for years and I made changes from time to time, this time there were many changes but I can't figure out what makes it fail now)
Question by:LeTay
  • 6
  • 4
LVL 39

Expert Comment

by:Geert G
ID: 37760218
have you tried starting the app with F8
and then menu search / find error > 00404B95
and see what line you get  ?

in debug options checking "use debug dcus" and recompile may help to indicate the source line

Author Comment

ID: 37761052
I could not locate "find error" in debug mode, search ...
Can you tell me precisely where the use debug dcu option is located ? I have a french version of Delphi
ps : in debug mode and in general in the IDE, I never had that error happening
LVL 21

Expert Comment

ID: 37761301
If the error was not happening before then I would recompile as it was before.  Add in one section of new code changes at a time and let the process tell you where the error is occurring.
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

LVL 39

Expert Comment

by:Geert G
ID: 37761471
find error is the bottom option of the search menu

Author Comment

ID: 37762336
Well, not on my Delphi 2009
There is no find error in the Search sub-menu, even grayed ...
There is however a goto address : is this what you mean

I am also interested in the "user debug dcu" but can't locate it

Author Comment

ID: 37762339
What is worrying me is that it seems that the exception occurs on a function call and not inside that function code itself, which is probably the place where it really happens
LVL 39

Expert Comment

by:Geert G
ID: 37764525
use debug dcus option can be found in compiler options
if you have source code of native delphi units like 'classes.pas' then you can debug into those units too

goto address, yes, name was changed and i didn't have delphi yesterday :)

Author Comment

ID: 37764709
About "use debug DCU", i suppose you mean that, if I set this option, later on at execution, it is crashes inside such unit, Madshi will report it ?
LVL 39

Accepted Solution

Geert G earned 2000 total points
ID: 37764855
there will probably be more detail in the debug report for the stack trace

doesn't the goto address give you a specific line of code for the first error ?

Author Comment

ID: 37764868
Goto give something but like this :  ?????

Author Comment

ID: 37770880
I changed the "use debug dcus" option to ON
When I build the project, I now get an error
It says that unit TEEngine was compiled with another version (of Delphi)
This unit is part of TEEChart that I use in the application
I guess I will have to upgrade to Delphi 2009 for having the compilation completed ...

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
When you have multiple client accounts to manage, it often feels like there aren’t enough hours in the day. With too many applications to juggle, you can’t focus on your clients, much less your growing to-do list. But that doesn’t have to be the cas…
To export Lotus Notes to Outlook PST or Exchange and Domino Server files to Exchange Server or PST files with ease, go for Kernel for Lotus Notes to Outlook conversion tool. Through the video, you can watch the conversion process. A common user with…

589 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question