Q32771 matherr Gives Null Pointer in Multithreaded Program
C Compiler
5.10   | 5.10
MS-DOS | OS/2

Summary:
   Making an assignment to the exception structure in a user-defined
matherr function will cause the "R6001: Null pointer assignment" error
to be generated when using the multithread statically linked C
run-time library LLIBCMT.LIB.
   Microsoft has confirmed this to be a problem in Version 5.10 of the
C compiler. We are researching this problem and will post new
information as it becomes available.


More Information:
   The program below demonstrates the problem by generating a numeric
error, which causes the user-defined matherr function to be called.
   Compile the example with the following command line:

   cl /Alfw file.c /link llibcmt doscalls/NOE/NOD;

   The following is the sample program:

#define INCL_BASE
#include <malloc.h>
#include <os2.h>
#include <math.h>

void main(int,char**);
void main2(void);
int  matherr(struct exception*);

HSEM sem=0L;

 void main(argc,argv)
 int argc;
 char *argv[];
 {
    int handtype,flword;
    unsigned thread;
    char *arglist;

    thread = _beginthread(main2,malloc(16*1024),16*1024,arglist);
    DosSemSetWait(&sem,-1L);
}

 void main2()
{
   double a;
   a=pow(10.0,500.0) ;
   DosSemClear(&sem);
}


 matherr(x)
 struct exception *x;
{
   switch(x->type)
   {
      case DOMAIN:
      case SING:
         printf("Invalid function parameter");
         break;
      case OVERFLOW:
         printf("Numeric overflow");
         break;
      case UNDERFLOW:
         printf("Numeric underflow");
         break;
      case TLOSS:
      case PLOSS:
         printf("Numeric loss of accuracy");
         break;
      default:
         printf("Numeric error");
         break;
   }
   x->retval = 0.0;/* This assignment causes the error */
   return(1.0);
}


Keywords:  buglist5.10
Updated  88/07/29 14:28
