Subject: Re: spurious segfault (libpthread problem)
To: Michael Rauch <>
From: Lennart Augustsson <>
List: current-users
Date: 05/26/2003 22:00:51
I can repeat that.  Whatever the cause is (not enough stack with threads?),
it is certainly a(nother) pthread bug.

    -- Lennart

Michael Rauch wrote:

>I've discovered today that a program that would run fine beforehand starts
>segfaulting when I add our new native libpthread to the list of libraries
>that are linked in.
>I was able to boil the problem down to this C program:
>---- gendict.c ----
>#include <stdio.h>
>#include <stdlib.h>
>int main(int argc, char* argv[]) {
>	int i;
>	int charArray[0x10000];
>	for (i = 0; i < 0x10000; i++) {
>		charArray[i] = 0;
>	}
>	return 0;
>}       // End of main
>---- ----
>Compiling the code as
> /usr/bin/gcc -o test2 gendict.c
>results in a correctly running binary. But if I additionally link in
> with
> /usr/bin/gcc -o test2 -lpthread gendict.c
>the program dies with a segmentation fault in the for-loop at i=1545 in the
>line "charArray[i]=0".
>Am I doing something wrong or should this segfault really not happen?
>My system: 
>NetBSD zonk 1.6S NetBSD 1.6S (ZONK) #0: Sun May 11 17:34:02 CEST 2003
>root@zonk:/usr/src/src/sys/arch/i386/compile/ZONK i386
>(sources from a few hours earlier)