Microsoft KB Archive/86068

= FIX: QuickWin Copying Large Selection Causes GP Fault =

Article ID: 86068

Article Last Modified on 10/23/2003

-

APPLIES TO


 * Microsoft FORTRAN Compiler 5.1
 * Microsoft FORTRAN Compiler 5.1

-



This article was previously published under Q86068



SYMPTOMS
Running a QuickWin application created by Microsoft FORTRAN version 5.1 for MS-DOS and OS/2 that outputs a large quantity of output to a child window, and then selecting a large amount of the output and choosing Copy from the Edit menu, may cause a general protection (GP) fault under Windows 3.1 or an unrecoverable application error (UAE) under Windows 3.0. If a smaller (yet still large) region is selected, a dialog box may be generated with the following error:

QWIN Warning

Out of Memory



CAUSE
The Copy menu item does a call to the Windows GlobalAlloc API to allocate memory from the global heap. QuickWin applications calculate the size of the allocation by using a RECT Windows structure containing the dimensions of the selection. The elements of this structure are only 2-byte integers and when a very large region of text is selected, the integer values overflow. The resulting handle returned from the GlobalAlloc function is invalid. The subsequent attempt to use the allocated memory causes a GP fault. The QWIN Warning dialog box is generated when the size of the selection is small enough to not overflow the integer elements of the RECT structure but too big for GlobalAlloc to succeed.



RESOLUTION
Do not attempt to copy extremely large areas of text in a QuickWin application child window at one time. Select and copy smaller regions.



STATUS
Microsoft has confirmed this to be a problem in Microsoft FORTRAN version 5.1 for MS-DOS and Windows. This problem was corrected in FORTRAN PowerStation.



Sample Code
c The following code reproduces the problem:

CHARACTER*30 Out INTEGER i     Out = '123456789012345678901234567890' OPEN (1, FILE='USER') DO i=1,1000 WRITE (1,*) i, Out, Out END DO     END

c Run the above code and choose Select All from the Edit menu, then c choose Copy or Copy Tabs from the Edit menu to generate the general c protection fault. Decrease the loop to only 500 iterations and the c application will generate the QWIN Warning Out of Memory dialog box c when Select All and then Copy is performed. Note that the text must be written to an explicitly opened child window. If it is written to UNIT * then it will scroll off at the top of the window and the window will never contain sufficient information to reproduce the error.

Additional query words: 5.10 gp-fault

Keywords: kbfix KB86068

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.