How to survive / prevent a memory access violation crash ?

Windows specific questions.
K128
Posts: 33
Joined: Jun 14, 2011 3:23
Location: Kathmandu, Nepal

How to survive / prevent a memory access violation crash ?

Postby K128 » Jul 16, 2011 2:04

I have 'On error goto __' also tried with TRY CATCH Implementation from Cherry but my app crashes whenever it violates memory access.

Actually nothing to hide about, I am making a Library in FB which contains many exported functions one of which is an attempt to port 'C' language's VMDetect to FB and that's where the problem occurs it violates memory access and results in the app being crashed. Is there anyway to prevent the crash or do I have to abandon this attempt ?

Thanks....
cha0s
Site Admin
Posts: 5317
Joined: May 27, 2005 6:42
Location: Illinois
Contact:

Postby cha0s » Jul 16, 2011 14:13

Hey K128, check out GDB which is a debugger. Perhaps you'll be able to gain some insight by crashing the program inside the debugger.

http://www.freebasic.net/wiki/wikka.php ... gerRunning
SARG
Posts: 1226
Joined: May 27, 2005 7:15
Location: FRANCE

Postby SARG » Jul 16, 2011 17:42

Why not try Fbdebugger ;-)

There is a possibility to change some values on fly in case of crash.

http://www.freebasic.net/forum/viewtopic.php?t=13935
K128
Posts: 33
Joined: Jun 14, 2011 3:23
Location: Kathmandu, Nepal

Postby K128 » Jul 17, 2011 1:14

Thanks @cha0s And @SARG for your reply.

I will surely try the debuggers too but I have a deep feeling that debugging wont help, because VMDetect makes an intentional memory access violation and Exception Handling is intentionally used to catch any exception that may occur if it is not a Virtual Machine. So, I think debugging wont help me much in this. Is there any method in FB to catch memory access violation error(s) and continue the program excution?

Thanks...
Mihail_B
Posts: 271
Joined: Jan 29, 2008 11:20
Location: Romania
Contact:

Postby Mihail_B » Sep 12, 2011 14:38

K128 wrote:Thanks @cha0s And @SARG for your reply.

I will surely try the debuggers too but I have a deep feeling that debugging wont help, because VMDetect makes an intentional memory access violation and Exception Handling is intentionally used to catch any exception that may occur if it is not a Virtual Machine. So, I think debugging wont help me much in this. Is there any method in FB to catch memory access violation error(s) and continue the program excution?

Thanks...


IPC - inter process comunication - "modularize" your program(s) ...
(Make from one exe more exes each inter-commed with each other ...)

when one app crashes ... the main module is still alive and it can re-load that module ...

You can try to see how [airport/train/life support] control applications are made ...

(in dos you can hook a cwsdpmi error handler ... if you have enough knowledge of PM mode apps ... there's got to be a way too for win32 if you just want to catch the error)
Cherry
Posts: 351
Joined: Oct 23, 2007 12:06
Location: Austria
Contact:

Postby Cherry » Sep 13, 2011 17:14

Please show me the code you used to catch the memory access violations with my try...catch implementation, because it simply can't crash this way, unless the exception handler gets messed up (which is unlikely).


You have to use it like this:

Code: Select all

#include "windows.bi"
#include "exceptions.bi"

Try(MyHandler) ' you can use *any* name instead of "MyHandler"
    ' put the code here which might crash
Catch(MyHandler, Else) ' "Else" will catch all exceptions. If you want to catch access violations only, use "EXCEPTION_ACCESS_VIOLATION" instead.
    ' if you want, put some code here which gets executed when the other code crashed, otherwise put no code here - but you still have to use a "Catch" block!
EndTry(MyHandler)

Return to “Windows”

Who is online

Users browsing this forum: No registered users and 5 guests