FIX: Stack Fault May Occur If Trapping Divide By Zero

Last reviewed: October 30, 1997
Article ID: Q95499
2.00 3.00 WINDOWS kbenv kbbuglist

The information in this article applies to:

- Microsoft Visual Basic programming system for Windows,

  versions 2.0 and 3.0

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 reference words: buglist2.00 buglist3.00 fixlist4.00 2.00 3.00
KBCategory: kbenv kbbuglist
KBSubcategory: EnvtRun
Keywords : EnvtRun kbbuglist kbenv
Version : 2.00 3.00
Platform : WINDOWS
Solution Type : kbfix


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: October 30, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.