BUG: Huge Array in C++ App May Cause General Protection FaultLast reviewed: July 17, 1997Article ID: Q102679 |
7.00 | 1.00 1.50
MS-DOS | WINDOWS
kbtool kbbuglist kbfasttip
The information in this article applies to:
The Microsoft C/C++ Compiler (CL.EXE) included with: - Microsoft C/C++ for MS-DOS, version 7.0 - Microsoft Visual C++ for Windows, versions 1.0 and 1.5
SYMPTOMSAn attempt to run an application developed in C++ for the Microsoft Windows operating system may fail and cause a general protection (GP) fault when the application accesses a huge array. If you create and run a version of the application for the MS-DOS operating system using the fast compiler, other errors may occur or the machine may hang. A similar application developed in C compiles and runs without error.
CAUSEThe fast compiler does not correctly create the far data segments required to support a huge array in a C++ application.
RESOLUTIONModify the compiler command line to specify the /f- compiler option switch to build the application with the optimizing compiler.
STATUSMicrosoft has confirmed this to be a problem in C/C++ compiler versions 7.0, 8.0, and 8.0c for MS-DOS. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
MORE INFORMATIONMicrosoft C/C++ version 7.0 and the Professional Edition of Visual C++ include the optimizing compiler. To build an application with the optimizing compiler, specify the /f- compiler option switch or perform the following three steps to modify options in Visual Workbench:
The following C++ code example demonstrates this problem when you build it either as an MS-DOS or as a QuickWin application. The MAP file shows that the compiler builds only one far data segment to hold the contents of the huge array. Because the array dimension in the application is 64,000, the application requires four far data segments to hold all the data.
Sample code
/* * Compiler options needed: /AL * Linker options recommended: /MAP */long __huge array[64000L];
void main(void){ long i; for (i = 0; i < 64000L; i++) array[i] = i;}
|
Additional reference words: 7.00 8.00 8.00c 1.00 1.50 gp-fault link
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |