BUG: GP Fault in SHW0.DLL When Starting to Debug

ID: Q114079

1.00 1.50 WINDOWS kbtool kbbuglist kbfixlist

The information in this article applies to:

SYMPTOMS

When starting an application for debugging in CodeView for Windows or in the Visual WorkBench debugger, a General Protection Fault occurs in SHW0.DLL at 0001:83BA.

CAUSE

This is actually the result of two bugs, one in the Microsoft C/C++ compiler, version 8.0, and one in the debuggers (CodeView for Windows and the Visual WorkBench debugger).

The compiler bug occurs when using the #pragma code_seg preprocessor directive to specify more than one segment in a single source file. C/C++ for MS-DOS version 8.0 will generate incorrect CodeView line- number information when the object module is compiled with the optimizing compiler (/f-). The sample code shown below illustrates this problem.

The problem with the debuggers occurs when an application, either an executable or a dynamic link library, has greater than 64K of type information. CodeView for Windows versions 4.0, 4.01, 4.05, and 4.10 and the Visual Workbench debugger versions 1.0 and 1.5 will cause a General Protection Fault when loading the types table.

RESOLUTION

Since this is a two-part problem, it requires a two-part resolution. The proper line number information can be generated by using the fast compiler. Use of the fast compiler can be forced by specifying the /f compiler switch. The debugger memory allocation bug can be worked around by reducing the amount of type information. Microsoft Knowledge Base article Q112335 deals with a similar problem which causes CVPack to generate a CK4009 error. This article also details methods for reducing the amount of type information.

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. The compiler problem was corrected in C/C++ Compiler version 8.0c, which is included with Visual C++ for Windows, version 1.5. Microsoft is researching the debugger problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

Sample Code

/* Compile options needed: /c /Od /f- /AL /Zd
*/ 

#include <stdio.h>

#pragma code_seg("test_seg")

void func(void)
{
    printf("This is func().\n");
}

#pragma code_seg("test_seg1")

void func1(void)
{
    _asm nop
    printf("This is func1().\n");
}

#pragma code_seg("test_seg2")

void func2(void)
{
    printf("This is func2().\n");
}

Additional reference words: 8.00 1.00 1.50 4.00 4.01 4.05 4.10 KBCategory: kbtool kbbuglist kbfixlist KBSubcategory: TlsMisc

Keywords          : kb16bitonly TlsMisc kbbuglist kbfixlist
Version           : 1.00 1.50
Platform          : WINDOWS

Last Reviewed: July 21, 1997