Diagnosing General Protection Fault or UAE in VB for Windows

ID: Q90871


The information in this article applies to:


SUMMARY

This article describes steps you can take to determine the cause of and possibly fix a general protection (GP) fault under Windows version 3.1, or an unrecoverable application error (UAE) under Windows version 3.0.


MORE INFORMATION

When diagnosing a GP fault, note the address and file where the GP fault occurred. Sometimes this is a known bug or problem. You can usually use the address and filename to query the Microsoft Knowledge Base to find a workaround or resolution.

However, sometimes the GP fault occurs in a range of address locations, so the specific address won't help. For example, this is the case with a bug in Visual Basic version 3.0 when using the IIF statement with temporary strings. This bug can result in a GP fault occurring within one of two ranges of addresses in VBRUN300.DLL or VB.EXE. For more information on this bug, please see the following article in the Microsoft Knowledge Base:

Q127069 : BUG: GP Faults from Using IIF with Temporary Strings

Dr. Watson logs provide the filename and address of the GP fault, but otherwise are not helpful in tracking down a GP fault created by a Visual Basic application.

Typical Causes of GP Faults

If not caused by a bug in the product, GP faults typically occur for one of the following reasons:

External Factors That May Influence a GP Fault

GP faults are not always consistent. If the problem is intermittent across different computers, analyze the answers to these questions:

Steps to Follow When You Get a GP Fault

  1. Always exit Windows after the GP fault. However, before exiting, note which programs were loaded in memory and what actions were taken that ended in the GP fault. The hope is that this paper log will help you identify a pattern for troubleshooting.


  2. See if the same procedure repeats the problem (likely).


  3. Use the Chkdsk or Scandisk utility to make sure your hard disk is healthy and clean.


  4. Check for viruses.


  5. Press CTRL+ESC to bring up the task list. Is anything in there? Close it all out if there is. Better yet, rename your Startup group by pressing ALT+ENTER in Program Manager; name it something like Xstartup. Then restart Windows, start Visual Basic, and run your application. Does the problem go away? If so, it may mean that something else is interfering or conflicting that results in the GP fault.


A GP fault may be a problem in the code, or it may be a symptom of some other situation. The key is to localize and repeat the conditions that resulted in the GP fault in order to better diagnose it. When you can isolate the minimum activities, programs, and external factors influencing a GP fault, you can determine if it is a problem with your code or something else.

Steps to Clean Code

To determine if a GP fault or UAE is caused by corrupted code, save the code in your forms and modules as text. Then load the code as text. This process cleans the internal representation of the code (P-code). In Visual Basic 3.0:
  1. In the Project window, select the form or module to clean.


  2. On the File menu, click Save Text, and click OK.


  3. On the File menu, click View Code.


  4. On the File menu, click Load Text, select the same file, and click Replace.


To determine if a GP fault or UAE is caused by a corrupted form, recreate the form. To recreate a form, add a new form to your project, and place new controls and menus on it to match the old form. Copy the code by saving code as text from the old form and loading as text into the new form. Finally, remove the old form, and rename the new form.

Steps to Recreate Form

In Visual Basic 3.0:
  1. On the File menu, click Add Form. Add the same controls and menus to this new form as are on the old form.


  2. In the Project window, select the old form or module.


  3. On the File menu, click Save Text, and click OK.


  4. On the File menu, click Remove File.


  5. In the Project window, select the new form.


  6. View the code from the Project window or by clicking Code on the View menu.


  7. On the File menu, click Load Text. Select the same code text file, and click Replace.


  8. Set the new form Name property to the old form's value.


You can also clean a project file (.MAK or .VBP file). Start a new project, and then add all the forms and modules to the new project.

Additional query words: 1.00 2.00 3.00 3.10 4.00 GPF vb416


Keywords          : PrgOptMemMgt 
Version           : WINDOWS:3.0,3.11,4.0
Platform          : WINDOWS 
Issue type        : 

Last Reviewed: May 28, 1999