views:

237

answers:

4

Ok my application does everything that is it suppeded to do and it does the same thing every time so its not as if testing was gone be that much trouble.

it crashes "somtimes" not always. it does this when i hover the mouse over a file in the open file dialog i have recently outputted. not instantly it waits about half second to a second, and i know that is when the openfiledialog brings up data such as file size and when it was created and what type of document it is..(standard)mouse hover info.. the thing is this is using the "opendialog" and i didnt write this code so this error is not of my doing is it?????? if it is how,, if it is not how/what can i do to stop it..

the type of error is a "acces violation at address " bla...

the open file dialog has no filters and is exactly as it off compoent tray and it crashes after i call "opendialog.execute"

i initialy thought that it may still be writing to it but then it continued after i stoped the app opening any new file untill the last one had compleated the save process.

as i said it doesnt even happen 100% all the time,, and its not machine specific.. crashes on 3 different win xp pc's.

HELP!!

Additional; findings i can open and run the file and all is well as long as i dont make a hint box to pop up on a file i have created.

+1  A: 

The open-file dialog is basically an explorer instance. Which means every shell extension you have installed gets loaded too. One problem with this is that once you use the open-file dialog, every shell extension also uses your stack to store variables/return addresses, ... If your stack is not big enough, this can lead to crashes.

Try increasing the stacksize of your application.

Stefan
Interesting, I'd never thought of this.
Greg D
In that case it would be a stack overflow, not an access violation. And you'd only run out of stack if all the extensions were executed concurrently. They're not. The shell runs each one separately.
Rob Kennedy
A stack overflow can result in any kind of crash, including an access violation.
Stefan
And the shell runs the extensions in multiple threads - at least on Vista and even (to a lesser degree) on XP.
Stefan
A: 

I propose you attach a debugger to the process, and find out what exactly makes the program crash. This should get you started...

Spikolynn
+3  A: 

Drop an TApplicationEvents component on your form and add an event handler for the OnHint event. Then put a break point in there and see if you can break on that before it crashes (as you said, it sounds like it is crashing when it tries to display the hint). Then you can compile with debug DCU's and trace in and see what it is crashing on.

My guess is you still have a file handle with an exclusive lock on the file maybe. Check your file handles and make sure you are properly closing them. What happens if you try to open one of those files from notepad while the program is running?

The intermittent behavior might be related to a different code path on an error condition that leads to a leaked file handle.

Good luck!

Jim McKeeth
Im not sure i understood you 100% Jim, i added a breakpoint on the 'onhint' for my applicationevent component..and nothing happens ..am i being stupid?
Arthur
yea i now know 100% its the hints or its happening when the hints go as i dont get the error if im fast or use arrow keys. still no idea why but ill now want to disable the hints.
Arthur
Check your file handles. Make sure you are not leaking one. What happens if you open the file with notepad, or mouse over it in explorer?
Jim McKeeth
well it opens in notepad without a quibble.
Arthur
No, Arthur, you don't want to disable hints. You want to fix the bug in your program that caused hints to break. Don't sweep the problem under the rug or you'll just get a lumpy rug.
Rob Kennedy
@Rob Kennedy - I wish I could up vote your comment.
Jim McKeeth
A: 

The access violation is most probably not related to the open dialog at all. I strongly you suggest you look in your code and make sure you are not over-writing memory bounds -if you are using dynamic arrays check and ensure that you are not accessing an element outside of its boundary; the same thing if you are manually allocating memory.

If you are not already using FastMM, use it. It has some good memory sanity checks.

like i said it crashes on the hint before i even click on the file or press enter or open.
Arthur