FIX: Stack Fault May Occur If Trapping Divide By Zero

ID: Q95499


The information in this article applies to:


SYMPTOMS

When trapping a divide by zero or divide overflow error (error numbers 11 and 6 respectively) in a Visual Basic program, you may receive a stack fault if an MS-DOS session is also running. In this situation, the computer may also hang (stop responding) or automatically reboot.


CAUSE

This problem is caused by the Windows mathematics exception handling, not by Microsoft Visual Basic.


WORKAROUND

The only way to avoid this problem is to terminate all MS-DOS sessions before running a Visual Basic application that traps divide by zero or divide overflow errors.


STATUS

Microsoft has confirmed this to be a bug in Microsoft Windows version 3.1. This problem has been corrected in Visual Basic version 4.0.


MORE INFORMATION

Steps to Reproduce Problem

  1. Start an MS-DOS session in Windows. If the MS-DOS session appears full screen, press ALT+ENTER to make it a windowed session.


  2. Minimize the MS-DOS window.


  3. Start Visual Basic or from the File menu, choose New Project (ALT, F, N) if Visual Basic is already running. Form1 is created by default.


  4. Add the following code to the Form_Click event procedure of Form1:
    
       Sub Form_Click ()
          On Error Resume Next
          Top:
             x% = DoEvents()
             y% = 1 \ 0  'This will cause a division by zero error
          GoTo top
       End Sub
     


  5. From the Run menu, choose Start (ALT, R, S) or press the F5 key to run the program.


  6. Click in the Form1 form. You may receive a stack fault here. if not, continue with step 7.


  7. Double-click the minimized MS-DOS session icon to restore it.


You should receive the message "VB caused a Stack Fault in module VB.EXE at 0001:0009."

Additional query words: buglist2.00 buglist3.00 fixlist4.00 2.00 3.00


Keywords          : kbenv EnvtRun 
Version           : 2.00 3.00
Platform          : WINDOWS 
Issue type        : 

Last Reviewed: June 18, 1999