Question

In Delphi 2009, my program now produces a "List index out of bounds" error. It generates a popup box:

alt text
(source: beholdgenealogy.com)

I'm using the "Debug" Build Configuration that has all the Runtime error checking turned on. But this does not capture the error before it happens.

Is there any simple way to locate the source of this error in my program without having to put in breakpoints and narrow it down by trial and error?

Was it helpful?

Solution

Do you have "Stop on Delphi Exceptions" turned on? (Tools\Debugger Options\Language Exceptions [Delphi7]) Otherwise it won't break in your sourcecode.

Also make sure that EListError is not in your "Exception Types to Ignore" list. This list is also found at Tools\Debugger Options\Language Exceptions (Delphi 7).

OTHER TIPS

madExcept (free) or EurekaLog (paid) may help. You can set them up to show/email a stack trace when an error occurs. I use EurekaLog in all my projects and it is invaluable for fixing these kinds of things.

Hey, you don't need any additional tools to track this! :)

Just run your application under debugger and make sure that "Stop on Delphi Exceptions" (or whatever it is called in your Delphi's version) is turned ON.

When exception occurs - there will be a notification from debugger. Press "Ok"/"Debug" button and just view the call stack. Call stack window is shown automatically in recent Delphi's version. If you can not see it - go to "View"/"Debug Windows"/"Call stack".

That's all. The call stack will point you at the exact location of the problem. No additional tool needed.

Those tools (EurekaLog, JCL or madExcept) are needed if you distribute your program among users and want to gather bug-reports about problems on client side. I.e. there is no debugger to check the problem.

As this is an RTL/VCL error, you often end up with better breaking/callstack behaviour if you enable Debug DCU's (and rebuild).

Any hints what your application's doing when this occurs? A long loop? A button click?

When the application halts and you look at the call stack debug window, can you trace the call back to the last call from your code? The call stack won't tell you all of the conditions, but can narrow down the location.

Once you narrow down the call, a logging tool like CodeSite can be really useful. For instance, I often log loop control variables to figure out which iteration occurs last before the error, then it's a matter of identifying likely suspects.

for listbox, tstrings,... means that the index is beyond the list->count, . . example of tString->strnigs[?]; [?] is < 0 or > (tString->count-1) will result out of bounds error.

as for NMPop3, etc,... if use pop3client to fetch email, it has a bugs to some unix/? pop3 server, that I have came across using it to fetch email from mail.???.com but ok with some.

at last I have to rewrite my pop3client application with tclientsocket instead of tnmpop3. now works with every of the pop3server that I connected to.

hope this help & good luck

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top