NetBSD Problem Report #46581
From www@NetBSD.org Mon Jun 11 03:50:51 2012
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
by www.NetBSD.org (Postfix) with ESMTP id 1996C63B89C
for <gnats-bugs@gnats.NetBSD.org>; Mon, 11 Jun 2012 03:50:51 +0000 (UTC)
Message-Id: <20120611035050.5CE0863B882@www.NetBSD.org>
Date: Mon, 11 Jun 2012 03:50:50 +0000 (UTC)
From: naruse@airemix.jp
Reply-To: naruse@airemix.jp
To: gnats-bugs@NetBSD.org
Subject: Continuous pthread_create may fail on amd64
X-Send-Pr-Version: www-1.0
>Number: 46581
>Category: port-amd64
>Synopsis: Continuous pthread_create may fail on amd64
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: port-amd64-maintainer
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Jun 11 03:55:00 +0000 2012
>Closed-Date: Tue Aug 15 09:56:22 +0000 2017
>Last-Modified: Tue Aug 15 09:56:22 +0000 2017
>Originator: Yui NARUSE
>Release: 6.99.7
>Organization:
>Environment:
NetBSD kelvena.airemix.net 6.99.7 NetBSD 6.99.7 (GENERIC) #2: Thu May 17 14:42:34 JST 2012 naruse@kelvena.airemix.net:/usr/obj/sys/arch/amd64/compile/GENERIC amd64
>Description:
Below program fails on amd64 as following:
% cc -pthread thr.c&&./a.out
pthread_create: Resource temporarily unavailable
zsh: abort (core dumped) ./a.out
On the environment, ulimit -u is 160.
But it won't fail on i386.
It won't fail if sched_yield() is not commented out.
So it seems something is wrong.
#include <pthread.h>
#include <stdlib.h>
#define THREAD_COUNT 161
void *dummy(void *p) {
return NULL;
}
int main(void) {
int i;
pthread_t *threads = malloc(sizeof(pthread_t) * THREAD_COUNT);
for (i = 0; i < THREAD_COUNT; i++) {
if (pthread_create(&threads[i], NULL, dummy, &i)) {
perror("pthread_create");
abort();
}
//sched_yield();
}
return 0;
}
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: port-amd64/46581: Continuous pthread_create may fail on amd64
Date: Mon, 11 Jun 2012 11:23:37 +0200
I don't see what's wrong with this behaviour - you can not rely on your new
threads being scheduled before running into the resource limit on threads
in the creating for loop.
Am I missing something?
Martin
From: "NARUSE, Yui" <naruse@airemix.jp>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: port-amd64/46581: Continuous pthread_create may fail on amd64
Date: Tue, 12 Jun 2012 01:48:12 +0900
2012/6/11 Martin Husemann <martin@duskware.de>:
> The following reply was made to PR port-amd64/46581; it has been noted by=
GNATS.
>
> From: Martin Husemann <martin@duskware.de>
> To: gnats-bugs@NetBSD.org
> Cc:
> Subject: Re: port-amd64/46581: Continuous pthread_create may fail on amd6=
4
> Date: Mon, 11 Jun 2012 11:23:37 +0200
>
> =A0I don't see what's wrong with this behaviour - you can not rely on you=
r new
> =A0threads being scheduled before running into the resource limit on thre=
ads
> =A0in the creating for loop.
>
> =A0Am I missing something?
I'm sorry about confusing post.
What I described about sched_yield is useless.
The correct reproducible program is below and wrong platform is i386.
On amd64, it fails as ulimit specified.
But on i386, it completes working.
#include <pthread.h>
#include <stdlib.h>
#define THREAD_COUNT 161
void *dummy(void *p) {
sleep(100);
return NULL;
}
int main(void) {
int i;
pthread_t *threads =3D malloc(sizeof(pthread_t) * THREAD_COUNT);
for (i =3D 0; i < THREAD_COUNT; i++) {
if (pthread_create(&threads[i], NULL, dummy, &i)) {
perror("pthread_create");
abort();
}
sched_yield();
}
return 0;
}
--=20
NARUSE, Yui =A0<naruse@airemix.jp>
State-Changed-From-To: open->closed
State-Changed-By: maxv@NetBSD.org
State-Changed-When: Tue, 15 Aug 2017 09:56:22 +0000
State-Changed-Why:
There is no issue here. On NetBSD it's 'ulimit -r', and it does work
as expected on both i386 and amd64. I'm closing this PR.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.