QuickBasic Can Corrupt COMSPEC under PC-DOS 3.30, Maybe Hang (45891)






This article was previously published under Q45891

SYMPTOMS

Under certain circumstances, it is possible for the MS-DOS COMSPEC variable to become corrupted, and consequently, the system may hang. The circumstances vary among different versions of DOS. For example, it has been reported and confirmed to be a problem with PC-DOS Version 3.30. That is, the problem does not occur (under these circumstances) in other versions of PC-DOS or even MS-DOS.

STATUS

Microsoft has confirmed this to be a bug in Microsoft QuickBasic Versions 4.00, 4.00b, and 4.50 and Microsoft Basic Compiler Versions 6.00 and 6.00b. We are researching this problem and will post new information as it becomes available.

MORE INFORMATION

The steps required to make the program below corrupt the COMSPEC variable are as follows:

  1. Compile and LINK the example into an .EXE using QuickBasic Version 4.50.
  2. Reboot with PC-DOS Version 3.30.
  3. Execute the .EXE version of program.
  4. Set an environment variable at the DOS prompt (e.g. SET MYVAR=A:NEWCOM).
  5. Enter the QuickBasic editor.
  6. Immediately exit the editor, and the following message will appear:

    "Insert disk with newcom in drive A
    and strike any key when ready"

This error can also be achieved by POKEing a 7 into 9F86:0008, the address assigned in the offending statement.

Code Example

CALL TEST

' MakeSound is not called; only required to force stringarr
' in sub test to be allocated at the proper address (9f86:0000).
SUB MakeSound
   SOUND 880, 10
END SUB

SUB Test
      ' IntArr is declared to ensure that StringArr IS
      ' allocated at the proper address
   DIM IntArr(0 TO 794) AS INTEGER
   DIM StringArr(0 TO 4) AS STRING * 13  'Address 9F86:0000

      ' this is the offending statement -- can be any character
   MID$(StringArr(0), 9, 1) = CHR$(7)    'Address 9F86:0008

      ' StringArr ADDRESS IS PRINTED OUT FOR DIAGNOSTIC PURPOSES.
   PRINT "StringArr ADDRESS = " HEX$(VARSEG(StringArr(0))) ":" _
                                HEX$(VARPTR(StringArr(0)))
END SUB
				

Modification Type: Minor Last Reviewed: 1/9/2003
Keywords: KB45891