views:

68

answers:

2

I'm running Delphi 2009. When I try to view a form in the form editor I keep getting a stack overflow. So I did what anyone else would do. I used Delphi to debug itself or rather another instance of the IDE.

So I know where the overflow is occuring I just don't know what to do about it. There is a custom component on this form that is intercepting calls to TForm.WindowProc so it can respond to certain winapi messages. The stack overflow is occuring when the component invokes the real WindowProc.

When I break on the exception the call stack is filled with hundreds of calls to:

delphicoreide120.@Comppalmgr@TComponentPalettePageItemDelegate@CheckValid

So far I haven't had any luck tracking down the actual message being passed to WindowProc.

Any help would be appreciated.

Update

I've made some progress. Tracked down the message that appears to be setting this off. It's WM_CHILDACTIVATE. When this message gets passed to the form's WindowProc it sets off a series of calls within the IDE that ends with a stack overflow. Now I just need to figure out why.

+2  A: 

Can you break when the EStackOverflow exception itself is being generated (i.e. in the MapFault or ErrorHandler functions of the SysUtils unit) or only when the EStackOverflow already has been raised?

When you can't break: the stack might already be partially corrupted when the debugger kicks in.

If you can break there, do it, then try to browse up the stack (newer Delphi versions are better at that) to find the offending parameter in the WindowProc.

When debugging the Delphi form designer; it is very convenient to have a dual monitor or large screen setup: you can run the offending instance of Delphi on one (side) of your monitors, the debugging Delphi instance on the other.

Edit: though I mentioned large screen and side in my answer, to make the debugging steps even clearer:

  1. Start by make sure that the debugging and offending instance of Delphi do not overlap visually.
  2. Then slowly overlap more and more of the offending Delphi instance more and more until you get the stack overflow.

--jeroen

Jeroen Pluimers
+1 for the dual monitors. That's very useful in debugging.
Mason Wheeler
@Jeroen, @Mason: if you don't have dual monitors (yeah some of us suffer that :-), make sure that the app's forms/windows are not covered by the IDE windows debugging it (in effect doing the same as with dual monitors). That will help immensely when dealing with messages going around as you don't get the app switches and repaints.
Marjan Venema
A: 

Ugh! It wound up being a third party component package I had recently installed and was completely unrelated to where the exception was occurring. Tried viewing a blank form in a new project with the same results.

Something went wrong either with the compilation or installation of the package. Rebuilding/reinstalling it made the exception disappear.

codeelegance