From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: bug with sysconf(_SC_CHILD_MAX) with user process ulimit set to unlimited
Date: Thu, 7 Dec 2017 12:05:40 -0500 [thread overview]
Message-ID: <20171207170540.GY1627@brightrain.aerifal.cx> (raw)
In-Reply-To: <20171207162609.45e02f83@ncopa-desktop.copa.dup.pw>
On Thu, Dec 07, 2017 at 04:26:09PM +0100, Natanael Copa wrote:
> Hi,
>
> While trying to debug why `bash -c 'sleep 1 & wait $!'` hangs with
> alpine in docker[1] I made an interesting discovery.
>
> Set user process ulimit to "unlimited" and run the following program on
> an x86_64 machine:
>
> #include <stdio.h>
> #include <unistd.h>
>
> int main() {
> long maxchild = sysconf(_SC_CHILD_MAX);
> printf("maxchild: %ld\n", maxchild);
> return 0;
> }
>
>
> With musl libc it prints:
>
> maxchild: 9223372036854775807
>
> With glibc it prints:
>
> maxchild: -1
>
>
> Setting the process ulimit to something like 64k makes bash work again.
>
> Shouldn't sysconf(_SC_CHILD_MAX) return -1 if ulimit is set to
> "unlimited"?
>
> Thanks!
>
> -nc
>
>
> [1]: https://github.com/tianon/docker-bash/issues/4
Yes, I think you're completely right. But this is also a bug in bash;
its loop to "round up to a power of two" is using the wrong type and
results in an infinite loop whenever the process limit it sees is
huge:
http://git.savannah.gnu.org/cgit/bash.git/tree/jobs.c#n768
I'll make sure the patch works right and then commit your fix.
Rich
prev parent reply other threads:[~2017-12-07 17:05 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-07 15:26 Natanael Copa
2017-12-07 17:05 ` Rich Felker [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171207170540.GY1627@brightrain.aerifal.cx \
--to=dalias@libc.org \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).