Subject: pthread problems on CS20 SMP system
To: None <port-alpha@netbsd.org>
From: Jarle Greipsland <jarle@uninett.no>
List: port-alpha
Date: 05/16/2004 19:17:21
Hi,

quite some time ago, I reported a problem (see PR
port-alpha/22219) where just the running of pthread-related
autoconf tests would panic a CS20 MP system.  This is still the
case.  However, I have distilled the autoconf tests into a small
program (see below).  This program, even when run as a
non-privileged user, will crash the system with a 'locking aginst
myself' message.

Has anyone had any success running native pthreads-based programs
on a multiprocessor alpha system?  On a CS20 MP system (or
similar)?  Can anyone run the program below on an alpha SMP
system *without* panicking the system?

Any suggestions for how to fix this bug?

					-jarle
----------------------------------------------------------------------
#include <sys/types.h>
#include <sys/time.h>
#include <unistd.h>
#include <pthread.h>
#ifndef NULL
#define NULL (void*) 0
#endif

static int fildes[2];

static void *task(p)
        void *p;
{
        int i;
        struct timeval tv;

        fd_set rfds;

        tv.tv_sec=10;
        tv.tv_usec=0;

        FD_ZERO(&rfds);
        FD_SET(fildes[0], &rfds);

        /* we're not interested in any fds */
        i = select(FD_SETSIZE, &rfds, NULL, NULL, &tv);

        if(i < 0) {
                perror("select");
                exit(10);
        }

        exit(0); /* if we exit here, the select blocked the whole process */
}

int main(argc, argv)
        int argc;
        char **argv;
{
        pthread_t t;

        /* create a pipe to select */
        if(pipe(&fildes[0])) {
                perror("select");
                exit(1);
        }

        pthread_create(&t, NULL, task, NULL);
        sched_yield();
        exit(2);
}