Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Thu, 7 Dec 2017 12:05:40 -0500
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Re: bug with sysconf(_SC_CHILD_MAX) with user process ulimit
 set to unlimited

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

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.