KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q41220: Program Hangs the Second Time It Is Run Using an 80287

Article: Q41220
Product(s): See article
Version(s): 5.00 5.10
Operating System(s): MS-DOS
Keyword(s): ENDUSER | | mspl13_c
Last Modified: 16-MAY-1989

When compiling a program that uses signal() with an 80287 coprocessor,
the first time the program runs, everything works correctly. But if
run a second time, it hangs the computer.

This problem has been confirmed to be with the old 80287 coprocessors
and has been corrected in newer 80287 chips.

The example program in the "Microsoft C for the MS-DOS Operating
System: Run-Time Library Reference" manual on Page 280 locks up on the
second time the program is executed with an old 80287. The following
is an example:

#include <stdio.h>
#include <signal.h>
#include <setjmp.h>
#include <float.h>

int fphandler ();
jmp_buf mark;
double a = 1.0, b = 0.0, c;

main()
{
    if(signal(SIGFPE, fphandler) == (int(*) () ) -1)
     abort();

    if(setjmp(mark) == 0)
    {
     c = a/b;
     printf("Should never get here\n");
    }

    printf("Recovered from floating-point error\n");
}

int fphandler (sig, num)
int sig, num;
{
    printf("signal = %d subcode = %d\n", sig, num);
    _fpreset();
    longjmp(mark, -1);
}

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.

Copyright Microsoft Corporation 1986-2002.