FIX: QuickWin Copying Large Selection Causes GP Fault

Last reviewed: September 16, 1997
Article ID: Q86068
5.10 | 5.10 MS-DOS | OS/2 kbprg kbfixlist kbbuglist kberrmsg

The information in this article applies to:

  • Microsoft FORTRAN for MS-DOS, version 5.1
  • Microsoft FORTRAN for OS/2, version 5.1

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.

MORE INFORMATION

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 reference words: 5.10 gp-fault
KBCategory: kbprg kbfixlist kbbuglist kberrmsg
KBSubcategory: FORTLngIss
Solution Type : kbfix


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 16, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.