NetBSD Problem Report #30749

From spz@serpens.de  Thu Jul 14 21:51:48 2005
Return-Path: <spz@serpens.de>
Received: from serpens.de (serpens.de [62.208.181.200])
	by narn.netbsd.org (Postfix) with ESMTP id B0F1E63B11A
	for <gnats-bugs@gnats.NetBSD.org>; Thu, 14 Jul 2005 21:51:47 +0000 (UTC)
Message-Id: <200507142151.j6ELpeRn008361@serpens.de>
Date: Thu, 14 Jul 2005 23:51:41 +0200 (MEST)
From: "S.P.Zeidler" <spz@serpens.de>
Reply-To: spz@serpens.de
To: gnats-bugs@netbsd.org
Subject: pthread_create ends in abort if stacksize limit over 4088k
X-Send-Pr-Version: 3.95

>Number:         30749
>Category:       port-amiga
>Synopsis:       pthread_create ends in abort if stacksize limit over 4088k
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    port-amiga-maintainer
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jul 14 21:52:00 +0000 2005
>Closed-Date:    Sat Jul 21 19:48:35 +0000 2018
>Last-Modified:  Sat Jul 21 19:48:35 +0000 2018
>Originator:     S.P.Zeidler
>Release:        NetBSD 2.0.2_STABLE
>Organization:
dis-
>Environment:
System: NetBSD serpens.de 2.0.2_STABLE NetBSD 2.0.2_STABLE (SERPENS) #0: Fri Jul 8 08:34:14 CEST 2005 spz@aquila:/home/netbsd/obj.amiga/sys/arch/amiga/compile/SERPENS amiga
Architecture: m68k
Machine: amiga
>Description:

--- snip ---
#include <pthread.h>
#include <stddef.h>

void *thread_routine(void *data) {
    return data;
}

int main() {
    pthread_t thd;
    pthread_mutexattr_t mattr;
    pthread_once_t once_init = PTHREAD_ONCE_INIT;
    int data = 1;
    pthread_mutexattr_init(&mattr);
    return pthread_create(&thd, NULL, thread_routine, &data);
}
--- snap ---
compiled by:
cc -o whatthehell -O2 -DNETBSD whatthehell.c -lm -lcrypt -lresolv
-lpthread

will, when run and stacksize limit is 4089k or higher, yield on my Amiga:
8% ./whatthehell && echo ok
Abort (core dumped)

(and it'll take around two minutes and brake all processes on the machine
to a standstill when it does that)

gdb says to that:
#0  0x0808a746 in kill () from /usr/lib/libc.so.12
#1  0x080f183c in abort () from /usr/lib/libc.so.12
#2  0x0805d8de in pthread__sa_start () from /usr/lib/libpthread.so.0
#3  0x08060816 in pthread_init () from /usr/lib/libpthread.so.0
#4  0x08060bcc in pthread_create () from /usr/lib/libpthread.so.0
#5  0x00002910 in main ()
#6  0x00002650 in __start ()

If my stacksize limit is 4088k or less it just finishes 'immediately'
and I get an 'ok' printed from the echo as fast as I can discern.

The problem doesn't occur in i386 or sparc64, but may be occurring in
other m68k architectures (testers?). It's been with us at least since
2.0RC1, probably longer.

>How-To-Repeat:
	see above
>Fix:
	workaround: lower stacksize limit :-P

>Release-Note:

>Audit-Trail:

State-Changed-From-To: open->analyzed
State-Changed-By: mhitch@netbsd.org
State-Changed-When: Mon, 09 Oct 2006 21:42:52 +0000
State-Changed-Why:
Problem analysis added to PR.


From: "Michael L. Hitch" <mhitch@lightning.msu.montana.edu>
To: gnats-bugs@NetBSD.org
Cc: port-amiga-maintainer@NetBSD.org, <gnats-admin@NetBSD.org>,
	<netbsd-bugs@NetBSD.org>, "S.P.Zeidler" <spz@serpens.de>
Subject: Re: port-amiga/30749: pthread_create ends in abort if stacksize
 limit over 4088k
Date: Mon, 9 Oct 2006 15:14:32 -0600 (MDT)

 On Thu, 14 Jul 2005, S.P.Zeidler wrote:

 > will, when run and stacksize limit is 4089k or higher, yield on my Amiga:
 > 8% ./whatthehell && echo ok
 > Abort (core dumped)
 >
 > (and it'll take around two minutes and brake all processes on the machine
 > to a standstill when it does that)

   I'd guess that writing the coredump is probably what stops everything
 until it finishes.

 > If my stacksize limit is 4088k or less it just finishes 'immediately'
 > and I get an 'ok' printed from the echo as fast as I can discern.
 >
 > The problem doesn't occur in i386 or sparc64, but may be occurring in
 > other m68k architectures (testers?). It's been with us at least since
 > 2.0RC1, probably longer.

   The problem is that pthread_sa_start() will allocate 16 stacks for 16
 upcall threads.  The amiga user address space is only 224M, of which 6M
 is available for text, 128M for data, and 32M for the process stack.
 The remaining space is where shared libraries and other mmap() regions
 are placed.  Attempting to mmap() 16 stacks of over 4088k will fail
 and pthread_sa_start() will call abort().

   The other architectures generall have a larger virtual address space
 for user processes and can take larger stacks.  The m68k architectures
 have varying virtual space configurations, and the ones using 4k pages
 with larger address spaces can panic on 68040 or 68060 cpus.

 >>Fix:
 > 	workaround: lower stacksize limit :-P

   USRSTACK in sys/arch/amiga/include/vmparam.h can be increased at
 the expense of more kernel memory used, and potentially allowing a
 user process to panic the system (at least until I fix the pmap
 limitations on the 68040/060).

 --
 Michael L. Hitch			mhitch@montana.edu
 Computer Consultant
 Information Technology Center
 Montana State University	Bozeman, MT	USA

State-Changed-From-To: analyzed->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sat, 21 Jul 2018 19:48:35 +0000
State-Changed-Why:
-4 was EOL'd a long time ago


>Unformatted:

 The bug no longer exists in netbsd-5 and can be laid to rest when netbsd-4
 gets EOLed.

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.