NetBSD Problem Report #32157

From www@netbsd.org  Thu Nov 24 12:14:54 2005
Return-Path: <www@netbsd.org>
Received: by narn.netbsd.org (Postfix, from userid 31301)
	id 7626E63BA19; Thu, 24 Nov 2005 12:14:54 +0000 (UTC)
Message-Id: <20051124121454.7626E63BA19@narn.netbsd.org>
Date: Thu, 24 Nov 2005 12:14:54 +0000 (UTC)
From: y0g1@poczta.wp.pl
Reply-To: y0g1@poczta.wp.pl
To: gnats-bugs@netbsd.org
Subject: pthread_create hangs netbsd
X-Send-Pr-Version: www-1.0

>Number:         32157
>Category:       kern
>Synopsis:       infinite loop calling pthread_create() hangs netbsd
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Nov 24 12:15:00 +0000 2005
>Closed-Date:    Sat Dec 31 04:44:16 +0000 2022
>Last-Modified:  Sat Dec 31 04:44:16 +0000 2022
>Originator:     iu1j4
>Release:        NetBSD 3.99.11
>Organization:
DLJ PROJECT
>Environment:
bash-2.05b$ uname -a
NetBSD siebert 3.99.11 NetBSD 3.99.11 (SIEBERT) #12: Sun Nov 13 13:30:27 CET 2005  root@siebert.dljproject.pl:/usr/src/sys/arch/amd64/compile/SIEBERT amd64
>Description:
#include <stdio.h>
#include <pthread.h>

void *fake_it(void *fake)
{
        pthread_exit(NULL);
}

int main(int argc, char **argv)
{
        pthread_t fake_pth;
        /*pthread_attr_t attr;
        pthread_attr_init(&attr);
        pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);*/
        while(1)        {
                pthread_create(&fake_pth, NULL, fake_it, NULL);
                /*pthread_join(fake_pth, NULL);*/
        }
        /*pthread_attr_destroy(&attr);*/
        return 0;
}


gcc -lpthread test.c -o test &&./test
it can hang your netbsd@amd64 machine (linux@amd64 the same)

>How-To-Repeat:
just compile the program and run it.
Of course the program has mistake, without it everything is ok.


>Fix:

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: gnats-admin->port-amd64-maintainer
Responsible-Changed-By: fair@netbsd.org
Responsible-Changed-When: Thu, 24 Nov 2005 13:26:05 +0000
Responsible-Changed-Why:

Wrong category; my best guess is that this is port-specific,
but the portmaster should review and correct me if necessary.



State-Changed-From-To: open->analyzed
State-Changed-By: chs@netbsd.org
State-Changed-When: Wed, 18 Jan 2006 17:07:05 +0000
State-Changed-Why:
the reason for the hang is that the kernel datastructures (amaps) that
describe the memory allocated by the memory-leaking program fill up kmem_map,
and then the system goes into an infinite loop trying to allocate more
memory.  the allocation will always fail since we're out of virtual space,
but since it's an M_NOWAIT allocation, the system just tries again immediately.
it switches back and forth between the test program and the pagedaemon
and nothing else gets a chance to run.

the result is slightly better with NKMEMPAGES_MAX_DEFAULT increased to 1GB.
the system no longer hangs completely, existing processes can still run
but processes trying to allocate more memory get stuck a different way
that I haven't looked into yet.


Responsible-Changed-From-To: port-amd64-maintainer->kern-bug-people
Responsible-Changed-By: ad@NetBSD.org
Responsible-Changed-When: Sun, 11 May 2008 22:56:35 +0000
Responsible-Changed-Why:
Kernel bug. There are no LWP limits.


From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: port-amd64/32157 (infinite loop calling pthread_create() hangs
 netbsd)
Date: Sun, 6 Oct 2013 09:35:59 +0000

 On Sun, May 11, 2008 at 10:56:36PM +0000, ad@NetBSD.org wrote:
  > Kernel bug. There are no LWP limits.

 There are LWP limits now, but since the test program has threads
 exit as soon as they start, that's unlikely to help.

 Anyone want to try this one on a crash machine with a recent kernel?

 -- 
 David A. Holland
 dholland@netbsd.org

From: coypu@sdf.org
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: port-amd64/32157 (infinite loop calling pthread_create() hangs
Date: Mon, 5 Aug 2019 22:52:43 +0000

 Well, it's not pretty to run this program.
 It blew up to using up almost 1TB of memory before it got killed for
 running out of swap.
 netbsd kept running at the end of it though.

State-Changed-From-To: analyzed->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sat, 31 Dec 2022 04:44:16 +0000
State-Changed-Why:
No longer crashes (as of 2019, should have got here sooner)


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2023 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.