What to do if your application crashes
From REALbasicWiki
| This article is a stub. You can help the REALbasicWiki community by expanding it. |
Sometimes, your application will crash, i.e. it unexpectedly quits and the REALbasic debugger does not display any error.
Of course, the fact that you get no clue from REALbasic about the reason why your application crashed makes the task more difficult than a simple "unhandled exception". So what can you do to track this bug down ?
[edit] Step 1: where does your application crash ?
You first need to determine exactly in which method your application crashes. Sometimes, it is pretty easy; for example, if everything is done in the Action event of a button without calling any other method than REALbasic built-in ones, then you know that the problem lies in this Action method.
Most of the time, however, the problematic method is a bit more difficult to locate because it calls/is called from another method. We will assume that the crash occurs because of a specific user-driven event (press a button, choose an menu item...). This will trigger an action whose method will, in turn, call other of your methods. The very first thing to do is to identify all the methods that can be called from the event that causes the crash; we will call it the method tree. Then:
- If one of the methods in the tree has a Declare statement, focus on this one first.
- If one of the methods in the tree uses a plugin, either a 3rd party plugin or a REALbasic built-in plugin (AddressBook, HTMLViewer, InternetEncodings, MD5, Regex, RBScript, Shell, XML), be aware that exceptions raised from a plugin may not be handled properly by REALbasic.
- If your code allow it, set a breakpoint at the beginning of the first method invoked then execute your code step by step until your application crashes. However, if you have a loop doing 20 or more iterations, it may be quite tedious to do step-by-step execution. In such a case, set a breakpoint before and after the loop and do a Resume between the both instead of Step. If the application crashes:
- Before the first breakpoint, you will know that the problem is before the loop
- Between the first and the second breakpoint, you will know that the problem lies in the loop.
- After the second breakpoint, you will now that the problem lies after the loop.
[edit] Step 2: why does it crash ?
...to be continued...
