Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Program closes itself

Status
Not open for further replies.

SLider3

Programmer
Jun 17, 2003
56
0
0
PT
I?ve made one program that basicaly reads and writes text files. The problem is that it sometimes closes itself without apparent reason.
Can someone please tell me what may be the cause of this?
 
It would be useful if you could give us some information about the way the program closes. You should try to isolate the part of the program that causes the crashes and see if you can reproduce the crash.
 
well....that is the problem.
There isn't a specific part of the program where it closes. Sometimes i just open it and it closes, other times i use it for a long time and it doesn't close.
I tried to find what may cause this but have no luck.
Nobody knows how can i solve this?
 
> Nobody knows how can i solve this?

Maybe somebody knows how to solve your problem, but not with the information that you have given. It's like calling your doctor and saying "Something is wrong with me, send me something to fix it", and then hanging up the phone. Of course He's not going to be able to diagnose your problem.

Most of us enjoy a challenge, so give us something to work with, like source code, a better description of the problem, the results of any debugging that you may have done etc. Also other information like does the program terminate quietly or does it throw an exception. What OS are you running on, what version of builder are you using and has it been patched with the latest patches, more specifics about what the program does etc. And of course, spend a bunch of time trying to duplicate the problem, if you can reproduce it you can usually solve it.

Good luck!
 
Maybe somebody knows how to solve your problem, but not with the information that you have given. It's like calling your doctor and saying "Something is wrong with me, send me something to fix it", and then hanging up the phone. Of course He's not going to be able to diagnose your problem.
Yeah, you are right but I really don't know what can I tell you that will help you finding the solution for my problem. I?m expecting someone had the same problem and kows how to solve it.

Most of us enjoy a challenge, so give us something to work with, like source code, a better description of the problem, the results of any debugging that you may have done etc. Also other information like does the program terminate quietly or does it throw an exception. What OS are you running on, what version of builder are you using and has it been patched with the latest patches, more specifics about what the program does etc.
- Source? as I don't know where is the problem i don't know wich parte of my code should i put here.
- The program basicaly reads/writes text files with movies subtitles.
- I'm using BCB6 (build 10.155) .... never patched it
- I'm using Win XP professional

And of course, spend a bunch of time trying to duplicate the problem, if you can reproduce it you can usually solve it.
That is the problem!! Sometimes my program closes when i?m doing a certain thing, then i repeat the same process a lot of times and it doesn't close. Ans as I said above, sometimes i just open it and suddenly it closes, and other times i use it for a long time and nothing happens.
 
You keep saying "close." Does it close, that is, run to completion unexpectedly, or does it crash, that is, do something to piss off the OS so it gets killed?

 
When i say "close" i mean the program auto-close (quitely) ....no error nor crash (the OS doesn't say nothing), it just closes.
 
Well, if it closes "controlled" you need to see through your termination conditions.

All programs i make i do have som mean of terminating them as do you i expect.

Obviously some condition of termination is fullfilled as it shuts down controlled.

A way of doing a check is to place a routine that writes out the termination variables in a file (plain text) and place at call to that routine in the shut-down-chain. This will give a hint of WHAT-THE-H%(%&/ went wrong.

Totte
 
A way of doing a check is to place a routine that writes out the termination variables in a file (plain text) and place at call to that routine in the shut-down-chain. This will give a hint of WHAT-THE-H%(%&/ went wrong.
I´m not sure of what info should i put in that file! What is the "shut-down-chain"? and how do i write that file when my program auto-closes? (because it only auto-close some times and that file should be like a "crash report" (but without crash) when the program has this weird behaviour). Please help me. :)
 
Well, there's a standart way of shutting down your program, right???

It's possible to capture that and put in a simple routine that writes in plain text to a file what is going on:

if you choose to terminate the program by clicking on the "End"-button it would be suitable to save the text "Klicked on END-button\r\n".

If a memory allocation went wrong it could be nice to know: "Memory allocation at xxx went wrong.\r\n"

And so forth.

It could be that several parameters/variables are active in shutting the program down, print out those parameters in plain text.

The routine could be called by the edit form->OnClose event...

Totte
 
> - I'm using BCB6 (build 10.155) .... never patched it

I did have some really strange things happening before I applied the latest patches. You may want to try installing the latest upgrade from Borland before doing anything else. You need to be registered with Borland to download it.

Go to:


Under the Registered users section choose updates for version 6.

Good luck!
 
If the program "crash" or "closes" or simply is doing something unexpected, try verifing the code with the debugger, something must be wrong with a pointer or a stack, I don't know.

I also wanna say and I don't know if is my suggestion or what, but the compiler makes different things every time you compile a program, I say this because, sometimes when I'm debbugin it jumps some lines of code without any reason.

Getting back to you question, debug step by step your code.


--- LastCyborg ---
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top