Hi all, got an issue with my app occasionally (not always) crashing on someone's PC with error 0x0000005. According to Google, that's an invalid memory access error. I've never seen the crash and my app runs 24/7 on my PC, but that's no excuse to ignore it. The app has lots of threads (with safety on) and background stuff happening, so I literally have no idea how to work out what might be going wrong. I've done all the usual good coding practices of checking if setting something was successful (not 0 result), and that buffers are large enough for things (like Base64 encoding), etc.
My question is: can I somehow use the OnError lib to "catch" this error in real-time, and maybe report where it's occurring in my app? I added PureBasic's "OnError" handler code to it. Apparently it'll show me the line number and other info when a crash occurs... although I don't see how from a compiled exe?
Thanks.
How to handle app crashing?
Re: How to handle app crashing?
Onerror can intercept any error, and it is advisable to put it systematically at the beginning of the code, for example like this.
(the simplest form of an error handler: all errors. Avoid direct Windows message "Application will close")
But to get the line number, the EXE must have been compiled with a special option /LINENUMBERING (which slows it down). See Help
(the simplest form of an error handler: all errors. Avoid direct Windows message "Application will close")
Code: Select all
EnableExplicit
; To test on IDE desactivate debug mode
OnErrorGoto(?ErrorHandler)
; Main code
; Make some error to test
PokeS(10, "Hello World") ; Cause a #PB_OnError_InvalidMemory error
MessageRequester("OnError test", "This should never be displayed")
End
ErrorHandler:
MessageRequester("Error", ErrorMessage())
End
Code: Select all
Error
Invalid memory access
Re: How to handle app crashing?
Okay, so I'll re-compile my exe with OnError Lines support and see how it goes. Cheers!