threads/86004: libthr broken on amd64

Justin Shumaker justin at arl.army.mil
Sun Sep 11 21:00:43 PDT 2005


>Number:         86004
>Category:       threads
>Synopsis:       libthr broken on amd64
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-threads
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Sep 12 04:00:38 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     Justin Shumaker
>Release:        5.4 AMD64
>Organization:
U.S. Army Research Laboratory
>Environment:
FreeBSD xxx.army.mil 5.4-RELEASE-p6 FreeBSD 5.4-RELEASE-p6 #0: Wed Sep  7 17:41:09 EST 2005
>Description:
maping libpthread to libthr on AMD-64 causes multithreaded apps to core dump.
>How-To-Repeat:
Write a simple multithreaded test program in C.  Here is a snippet of my test appplication.  I have also tested with 3 other threaded apps all with the same results, so before complaining about a line of code in the below code, try cooking up your own.  The application runs with libpthread.

#include <stdio.h>
#include <pthread.h>

#define WORK_SIZE 1024*128*8

int queue;


void* work(void *ptr) {
  unsigned int i, q;
  float a;

  q = queue;
  while(q--) {
    a = 1;
    for(i = 0; i < 128; i++)
      a *= 1.001;
  }

  return 0;
}


int main(int argc, char *args[]) {
  unsigned int i, tnum, n;
  pthread_t t[8];

  if(argc < 2) {
    fprintf(stderr, "thread argument [1..8] required.\n");
    exit(1);
  }

  tnum = atoi(args[1]);
  if(tnum < 1 || tnum > 8) {
    fprintf(stderr, "thread number must be from 1 to 8\n");
    exit(1);
  }

  for(n = 0; n < 4; n++) {
    queue = WORK_SIZE / tnum;

    /* Launch the threads */
    for(i = 0; i < tnum; i++)
      pthread_create(&t[i], 0, work, 0);

    /* Join the threads and finish */
    for(i = 0; i < tnum; i++) {
      pthread_join(t[i], 0);
      printf("done: %d\n", i);
    }
  }

  exit(0);
}
>Fix:
No idea, will require combing the libthr source and finding 64-bit unfriendly code or something it's tickling in the kernel.
>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-threads mailing list