[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

kfreebsd i386 changing x87 precision mode in pthreads



hi,
I encountered a weird issue on kfreebsd i386 using pthreads. It seems to
change the x87 fpu precision mode (bits 8 and 9 of the control word) in
threads compared to the master. In the master its set to extended
precision, in child threads it changes to double precision. This breaks
equality of e.g. python-numpy's threaded and serial random number generator.

Is this expected? it doesn't happen on linux i386.
To reproduce use this simple file and gdb on fischer.debian.org:

$ cat test.c
#include <pthread.h>
#include <stdio.h>

void *thread_fun(void *x_void_ptr)
{
    printf("thread\n");
    return NULL;
}

int main()
{
    pthread_t thread;

    if(pthread_create(&thread, NULL, thread_fun, NULL)) {
        fprintf(stderr, "Error creating thread\n");
        return 1;
    }
    if(pthread_join(thread, NULL)) {
        fprintf(stderr, "Error joining thread\n");
        return 2;
    }
    return 0;

}

$ gcc test.c -g -pthreads

$ gdb ./a.out

(gdb) break main
Breakpoint 1 at 0x8048589: file test.c, line 14.
(gdb) break thread_fun
Breakpoint 2 at 0x8048561: file test.c, line 6.
(gdb) r
Starting program: /home/jtaylor/a.out

Breakpoint 1, main () at test.c:14
14          if(pthread_create(&thread, NULL, thread_fun, NULL)) {
(gdb) p $fctrl
$1 = 4991
(gdb) c
Continuing.

Breakpoint 2, thread_fun (x_void_ptr=0x0) at test.c:6
6           printf("thread\n");
(gdb) p $fctrl
$2 = 4735


Reply to: