开发者

Delphi AV vs Try-Except [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

Good day!

I have a multi-threads application with TaskManager, workers... And i have a 开发者_如何学Pythonproblem.

threads execute-method looks like:

try
 task.execute();
except
 on E : Exception do
 begin
   log(e.message);
   //  callResetThread/disconnectUser
 end;
end;

Each task have many Access Violations, runtime errors... Try-except for some cases does not help. Is there any solution for protect my program from the errors at threads...

Delphi 7/ no jedi/ default memory-managers

UPDATE

Dear friends! We have a code with many third-party components. This program raised 1-2 exception per week in single user mode. When we modify this program to work in server-mode with equal 500 clients we can have > 70 exceptions per day (1-2 may be critical and not catched try ... except ...end). We realy understand that we must fix all bugs :-). But source code (with third-party components) has size > 20 Mb... We realy need your help, HOW WE CAN CATCH THIS SYSTEM ERRORS (may be with using system methods).


Try-except isn't supposed to "help" with runtime errors. You're supposed to help by fixing the bugs in your program so that the access violations and other errors don't occur in the first place.

If an exception occurs and you don't know why, then there's nothing you can do in your program to fix the problem, so there's no reason for your program to continue running. For all you know, your program's memory is already corrupted, so the safest thing you can do is to terminate the program so as not put your customers' data in any more danger.

If a try-except block isn't catching exceptions, then either your program is so broken that you've overwritten the part of your program that handles exceptions, or the exceptions are occurring outside the try-except block.

You can try using an exception-logging library such as MadExcept, EurekaLog, or JclDebug. They detect exceptions in your program and record information to help you debug the problems.

Another possibility is that the debugger is interrupting your program when an exception occurs and showing you a message about it. That's the debugger, not your program, so if you then let your program keep running, you'll see your exception-handling code take over.


You HAVE to fix them ALL, really! The AV is not only a problem of the exception an the handling of it. Every exception (AV) throws you programm into some more or less "undefined" state, because your code tried to write or read some data into/from memory and the data is not valid. So the result of your App or the thing it is supposed to do is not working! And there is no "it is not possible"! It is for sure possible or you have to rewrite the code...


The only way for you to get higher resilience than try/except is to use separate processes (and after that, separate machines, then separate datacentres, etc.).

It sounds like the code you are using was not designed to be used with threads, never mind the heavy multi-threading that you'll see in a server application. I don't think your current approach is workable.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜