How to debug invalid pointer operation

I am developing a Windows application using Borland C++ Builder 6, to run on a Windows 7 pc and I am seeing an 'invalid pointer operation' error when the program terminates. There is little information to go on in the error message so I need to find a way of working out which pointer is causing the problem. What is the best way of going about debugging this?
What is the best way of going about debugging this?
Run it under debugger and see what operation causes this error.
I did this and the debugger stops at the following line in Forms.hpp :-
/* TCustomForm.Destroy */ inline __fastcall virtual ~TForm(void) { }

If I trace into that line I get a different exception:
...exe raised exception class EExternalException with message 'External exception C0000025'...

That does not help me much.
Last edited on
What is the callstack? What calls that function?
I'm not sure. It must be called by the line:-
Application->Terminate();
in my Exit event.
It seems that each of the forms in my application get destroyed until the last one, frmMain2 in MainForm.cpp, and it is that one that triggers the exception.
The exception only occurs if I use the OpenDialog to open a file in the Operating System. If I launch the program and don't open a file, the exception is not seen when I exit.
I can only assume that there is a pointer left to a file or to one of two arrays that are created following a file open. I thought I had NULLed and deleted the file pointer but I must have overlooked something as there is quite a bit of code.
Thanks for your assistance.
Topic archived. No new replies allowed.