[384] in Pthreads mailing list archive

home help back first fref pref prev next nref lref last post

Bug report: pthreads-1_60_beta5.

daemon@ATHENA.MIT.EDU (drh@tobit.vnet.net)
Thu Aug 15 09:46:19 1996

From: drh@tobit.vnet.net
Date: Thu, 15 Aug 96 09:12 EDT
To: proven@MIT.EDU, pthreads@MIT.EDU

The program below will normally core-dump within about 60 seconds on
a P90 (with the FDIV bug) running Linux 1.2.13 and pthreads-1_60_beta5.
GDB tells me the error is in the file stdlib/strtod.c.  The Balloc()
routine in this file appears to use static data (freelist[]) but is not
locked.  I'm working on a fix now, but do not have one available at
this writing.

Example code that exercises the problem follows.  The test program calls
sprintf() with a floating-point convertion repeatedly in many threads.
I normally run the test program with an argument of about 50.

/*
** A program demonstrate a problem with floating point to ASCII
** conversions in the standard library accompanying Provenzano pthreads,
*/
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>

/*
** Every thread begins execution with in the following function
*/
void *DoThread(void *clientData){
  int i;
  double v = 1.0009999999999999999999999;
  char zBuf[100];
  for(i=0; i<1000000; i++){
    sprintf(zBuf,"%3.1f",v);
  }
  pthread_exit(0);
}

/*
** Start up N threads, each running the same job.
*/
void main(int argc, char **argv){
  int i,N;

  if( argc!=2 ){
     fprintf(stderr,"Usage: %s  num-threads\n",*argv);
     exit(1);
  }
  N = atoi(argv[1]);
  for(i=1; i<N; i++){
    pthread_t threadId;
    if( pthread_create(&threadId,0,DoThread,0)<0 ){
      perror("Can't start a new thread");
    }else{
      pthread_detach(threadId);
    }
  }
  if( N>0 ){
    DoThread(0); 
  }
}

Thanks for all your help.
---------------
D. Richard Hipp     drh@tobit.vnet.net

home help back first fref pref prev next nref lref last post