Correcting Stack Errors and Stack Overflow Problems in Windows 95/98

Correcting Stack Errors and Stack Overflow Problems

Stack overflow issues are usually indicative of errors in the device driver. Device drivers are allocated 4 kilobytes, or one page, of space to be used as a stack. If the device driver requires the use of more than 4 kilobytes of memory, a stack overflow condition occurs.

Resolving the problem:

Solution #1:

  1. Click Start, Run and type in sysedit and click OK to open the System Configuration Editor.
  2. Select the SYSTEM.INI window by clicking on the top of the window to bring it forward.
  3. Scroll down to the [386Enh] section.
  4. Add the following line beneath the [386Enh] entry in SYSTEM.INI file. MinSPs=12 It will look like this:

    [386Enh]

    MinSPs=12

  5. Now click the “X” in the upper right of the SYSTEM.INI window to close it and save the file when requested to do so.
  6. Now exit the System Configuration Editor window by clicking the “X” in the upper right of the window.
  7. Restart your computer.

If the problem persists, increase the number of spare stack pages in multiples of 4. As an example, change the MinSPs= from 12 to 16, 32 or 64 etc. Each spare stack page requires 4 kilobytes of memory. This entry must not be an odd number and must always be in multiples of “4”.

Solution #2:

Some computers running MS-DOS related programs, especially those running early versions of Windows 95, require that the Stacks references be in the Config.sys file in the root of Drive “C”. This is to allow for 16-bit MS-DOS drivers.

At times, mysterious hangs or failures can occur when a hardware routine does not have enough storage space to perform its job. To avoid this problem, MS-DOS versions 3.2 and later provide additional storage space for the interrupt-handling code whenever a hardware interrupt occurs. This is done by changing the current storage area (called a “stack,” because it is a place to stack information temporarily) to a new storage area provided by MS-DOS. By default, nine of these stacks, each 128 bytes in size, are provided. The number and size of stacks can be increased using the CONFIG.SYS STACKS=n,m command, where n is the number of stacks and m is the size of each stack in bytes.

Changing the current stack takes time. It was discovered that changing the stack can slow the system enough that some programs, particularly high-speed communications programs, will fail. To avoid this problem, MS-DOS versions 3.3 and later allow disabling the stack swapping by specifying 0 stacks of 0 bytes in size (STACKS=0,0). Because the STACKS= command affects hardware- and configuration-dependent code, it can have unpredictable effects on your computer.

If a “stack overflow” or “exception error 12” (stack exception) error occurs, increasing the number and size of stacks specified in CONFIG.SYS may solve the the problem (for example, STACKS=18,256).

Note: STACKS= only affects hardware interrupts. If the stack being overflowed (trying to store too much information) is internal to an application, this entry in your CONFIG.SYS file probably will not solve the problem.

If the command STACKS=0,0 is in the CONFIG.SYS file and any instability occurs (including, but not limited to, printing problems and system hangs), remove the STACKS= command temporarily and test the system.

If the command STACKS=n,m is in CONFIG.SYS and problems occur (including, but not limited to, serial port problems), remove it temporarily and test the system. If problems continue and the system is an AT class machine, set STACKS=0,0; if the system is a PC, PC XT, or PC Convertible, set STACKS=9,128.

You should also take note of the fact that the STACKS= entry should be correctly entered in the CONFIG.SYS file.

Example:

files=20 buffers=20 lastdrive=z stacks=0,0 break=off dos=high,umb shell=c:\dos\command.com c:\dos /e:1024 /p device=c:\dos\himem.sys

device=c:\dos\emm386.exe NOEMS

It’s important to note that you may have to adjust the STACKS= entry until your system performs as you desire. MS-DOS 3.3 and later (including Windows 95/98) use special case codes that check for PC, PC XT, and PC Convertible. If any of these is detected, STACKS= defaults to 0,0. Otherwise, STACKS defaults to a value of 9,128.

The following are valid STACKS= arguments:

STACKS=16,256 STACKS=32,256 STACKS=64,256

STACKS=64,512

STACKS vs. STACKSHIGH

Using the syntax STACKS= as noted in the example above, loads the command into the lower memory areas of your computer. By changing the syntax to STACKSHIGH= supports the dynamic use of data stacks in upper memory areas to handle hardware interrupts.

Use Syntax:

STACKS=n,s as opposed to

STACKSHIGH=n,s

Parameter Values

n Specifies the number of stacks. Valid values for n are 0 and numbers in the range 8 through 64.

s Specifies the size (in bytes) of each stack. Valid values for s are 0 and numbers in the range 32 through 512.

Possible configurations:

The Window98/98SE defaults for MinSPs=8 when STACKS= or STACKSHIGH= is set in CONFIG.SYS to 9,256.

Set the MinSPs=12 and then set stackshigh in CONFIG.SYS as Stackhigh=12,256

Set the MinSPs=16 and then set stackshigh in CONFIG.SYS as Stackhigh=16,256
Set the MinSPs=32 and then set stackshigh in CONFIG.SYS as Stackhigh=32,256
Set the MinSPs=64 and then set stackshigh in CONFIG.SYS as Stackhigh=64,512

About Dewwa Socc