From: Michael Hudson-Doyle <michael.hudson@canonical.com>
To: Florian Weimer <fweimer@redhat.com>
Cc: Zack Weinberg via Libc-alpha <libc-alpha@sourceware.org>,
Zack Weinberg <zack@owlfolio.org>
Subject: Re: RFC PATCH: Don't use /proc/self/maps to calculate size of initial thread stack
Date: Wed, 14 Sep 2022 10:03:42 +1200 [thread overview]
Message-ID: <CAJ8wqtd+CYgUQgQ1hE0smM0ds2S=_eZOc=6e5G2VQuDor=HyCA@mail.gmail.com> (raw)
In-Reply-To: <87fsgvvbwq.fsf@oldenburg.str.redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1621 bytes --]
On Tue, 13 Sept 2022 at 21:53, Florian Weimer via Libc-alpha <
libc-alpha@sourceware.org> wrote:
> * Zack Weinberg via Libc-alpha:
>
> > When pthread_getattr_np is applied to the initial thread, it has to
> > figure out how big the initial thread's stack is. Since the initial
> > thread's stack is lazily allocated and the kernel reuses that memory
> > region for the "information block" (argv, environ, etc) there are
> > several different ways one could define "the size of the initial
> > thread's stack"; for many years, the NPTL implementation has said that
> > the stack starts at __libc_stack_end, rounded in the opposite
> > direction from stack growth to the nearest page boundary, and extends
> > for getrlimit(RLIMIT_STACK).rlim_cur bytes, *minus the size of the
> > information block*, which is beyond __libc_stack_end. The rationale
> > is that the resource limit is enforced against the entire memory area,
> > so if we don't subtract the size of the information block, then the
> > program will run out of stack a few pages before pthread_attr_getstack
> > says it will.
>
> Do we actually have to subtract the size of the information block?
> One could argue that this is just part of the arguments passed to main,
> so sort-of-but-not-quite part of main's stack frame.
>
> process_vm_readv seems quite likely to get blocked by seccomp filters.
>
> Maybe we can get the kernel to pass the end of the stack in the
> auxiliary vector?
>
I wondered the same when reading the first mail fwiw -- guessing what the
kernel did is always going to be more annoying than just having it tell
us...
Cheers,
mwh
next prev parent reply other threads:[~2022-09-13 22:03 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-09 21:03 Zack Weinberg
2022-09-13 9:52 ` Florian Weimer
2022-09-13 22:03 ` Michael Hudson-Doyle [this message]
2022-09-15 16:09 ` Zack Weinberg
2022-09-20 12:16 ` Florian Weimer
2022-09-21 12:41 ` Zack Weinberg
2022-09-21 13:01 ` Florian Weimer
2022-09-21 20:58 ` Adhemerval Zanella Netto
2022-09-23 14:59 ` Zack Weinberg
2022-09-23 15:24 ` Adhemerval Zanella Netto
2022-09-23 18:57 ` Florian Weimer
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='CAJ8wqtd+CYgUQgQ1hE0smM0ds2S=_eZOc=6e5G2VQuDor=HyCA@mail.gmail.com' \
--to=michael.hudson@canonical.com \
--cc=fweimer@redhat.com \
--cc=libc-alpha@sourceware.org \
--cc=zack@owlfolio.org \
/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.
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 read-only IMAP folder(s) and NNTP newsgroup(s).