Subject: Re: mit-threads don't work?
To: Christian Groessler <cpg@aladdin.de>
From: Jaromír <jdolecek@netbsd.org>
List: tech-pkg
Date: 07/21/2001 12:03:10
I'd expect this happen if you'd get the pthread library compiled
from old version of system (I think the sys_errlist[] changed
in NetBSD 1.4). Are you sure you have mit-pthreads for 1.5.1/current?
Which version do you have (pkg_info mit-pthreads) ? It might help
to recompile mit-pthreads. Anyway, you probably want to compile your program
with -D_REENTRANT. You might also try to call pthread_init()
on start of main() - even through you are not using pthreads, mit-pthreads
might override some libc stuff and break if not initialized.
GDB stacktrace would also help to find out where the program crashes.

Jaromir

Christian Groessler wrote:
> Hi,
> 
> sorry for the cross-posting, but I think it started recently
> (therefore current-users, but I don't have an old version to verify)
> and the problem is in a pkg (-> tech-pkg):
> 
> I'm not even using pthread stuff in this demo, just linking with the
> pthread lib:
> 
> Program:
> 
> -------------
> #include <sys/fcntl.h>
> #include <errno.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <pthread.h>
> #include <unistd.h>
> #include <string.h>
> 
> 
> int main(int argc, char **argv)
> {
>     int ha;
> 
>     ha = open("/dev/usb0", O_RDONLY);
>     if (ha == -1) {
>         fprintf(stderr, "error: %s\n", strerror(errno));
>         exit(1);
>     }
>     printf("success\n");
>     close(ha);
>     return(0);
> }
> -------------
> 
> How I compile:
> 
> cc -I /usr/pkg/pthreads/include -g pthreads.c -o pt -L/usr/pkg/pthreads/lib -Wl,-R,/usr/pkg/pthreads/lib -lpthread
> 
> (N.B. I get a warning when doing this:
> 
> /usr/pkg/pthreads/lib/libpthread.so: warning: reference to compatibility sys_errlist[]; include <errno.h> for correct reference
> /usr/pkg/pthreads/lib/libpthread.so: warning: reference to compatibility sys_nerr; include <errno.h> for correct reference
> 
> )
> 
> The resulting program segfaults when doing the open:
> 
> gibbon:~/tmp$ ./pt 
> Segmentation fault (core dumped)
> 
> This happens on both i386 and macppc. On alpha it seems to work,
> but my real progam shows later funny behaviour.
> 
> Should I do a send-pr?
> 
> regards,
> chris
> 


-- 
Jaromir Dolecek <jdolecek@NetBSD.org>      http://www.ics.muni.cz/~dolecek/
NetBSD - just plain best OS! -=*=- Got spare MCA cards or docs? Hand me them!