unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Zack Weinberg <zackw@panix.com>
To: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Cc: GNU C Library <libc-alpha@sourceware.org>
Subject: Re: Fwd: What can a signal handler do with SIGSTKSZ?
Date: Mon, 14 Jan 2019 11:34:22 -0500	[thread overview]
Message-ID: <CAKCAbMjd-zL5kcoLZJKz++NkAnB5vS_yE-D6QAqicosdythu9w@mail.gmail.com> (raw)
In-Reply-To: <32971978-77ca-57f4-2524-560f53008be4@linaro.org>

On Mon, Jan 14, 2019 at 6:29 AM Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:
> On 14/01/2019 09:18, Szabolcs Nagy wrote:
> >
> > as far as i know aarch64 kernel calculates and reports worst
> > case stack frame size precisely, so that's probably just an
> > x86 issue.

That's good to hear.  All of the architectures' signal frame
construction code should be checked and updated if necessary -- alas,
I doubt there's any good way to automate the problem, since signal
delivery is so low-level and arch-specific (but I'm not a kernel
hacker).

> > i think proposing sysconf(_SC_{MIN}SIGSTKSZ) for posix is the
> > right solution with the kernel providing an upper bound of the
> > stack frame in AT_MINSIGSTKSZ (as it already does on aarch64).
> >
> > with the current wording of the standard SIGSTKSZ and MINSIGSTKSZ
> > definition cannot be omitted when they are runtime variables,
> > so posix needs to be updated.
>
> From an implementation standpoint, how the lib would calculate _SC_SIGSTKSZ?
> Just plus constant based on _SC_MINSIGSTKSZ? If it is the idea we might go
> only with _SC_MINSIGSSTKSZ and export the value adjustment instead.

That seems fine to me.

For this new interface, the backward compatibility concerns I raised
regarding what you can do in MINSIGSTKSZ don't necessarily apply, and
it would make sense for it to be truly a minimum.  I would suggest we
define "minimum" in terms of what the C standard - not POSIX - allows
you to do in a signal handler, which is almost nothing:  you're
guaranteed to have enough space in sysconf(_SC_MINSIGSTKSZ) for this:

    static volatile sig_atomic_t signal_flag = 0;
    static void handler(int unused)
    {
       flag = 1;
    }

and this:

   static atomic_uint signal_count = 0;
   static void handler (int unused)
   {
      atomic_fetch_add (&signal_count, 1);
   }

but *not* for this:

   static int sockets[MAX_SOCKETS];
   static void handler (int sig)
   {
      for (int i = 0; i < MAX_SOCKETS; i++)
      {
          if (sockets[i] == -1) continue;
          write (sockets[i], "\r\n500 Service shutting down
unexpectedly\r\n\r\n", 44);
          close (sockets[i]);
      }
      signal (sig, SIG_DFL);
      raise (sig);
   }

or for anything for which you would need to use SA_SIGINFO, or for
recursive signal delivery.

zw

  reply	other threads:[~2019-01-14 16:34 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-11 17:44 What can a signal handler do with SIGSTKSZ? Carlos O'Donell
2019-01-11 19:02 ` Szabolcs Nagy
2019-01-11 19:11   ` Carlos O'Donell
2019-01-11 20:23     ` Szabolcs Nagy
     [not found] ` <CAKCAbMiCaBst_ofjKkH3Ck1CoOV86wPKv3QSkC89XW_zu=1BLA@mail.gmail.com>
2019-01-11 19:34   ` Fwd: " Zack Weinberg
2019-01-11 20:00     ` Florian Weimer
2019-01-11 20:06       ` Christian Brauner
2019-01-11 20:14         ` Florian Weimer
2019-01-11 20:26           ` Christian Brauner
2019-01-14 16:15             ` Florian Weimer
2019-01-11 20:09       ` Zack Weinberg
2019-01-11 20:29         ` Florian Weimer
2019-01-11 23:59           ` Zack Weinberg
2019-01-14 11:18             ` Szabolcs Nagy
2019-01-14 11:29               ` Adhemerval Zanella
2019-01-14 16:34                 ` Zack Weinberg [this message]
2019-01-14 20:29                   ` Carlos O'Donell
2019-01-14 16:18               ` Florian Weimer
2019-01-14 16:22                 ` Carlos O'Donell
2019-01-14 16:31                   ` Florian Weimer
2019-01-14 16:34                   ` Szabolcs Nagy
2019-01-14 18:19                   ` Joseph Myers
2019-01-14 20:30                     ` Carlos O'Donell
2019-01-16 22:51             ` Christian Brauner
2019-01-11 19:40 ` 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

  List information: https://www.gnu.org/software/libc/involved.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAKCAbMjd-zL5kcoLZJKz++NkAnB5vS_yE-D6QAqicosdythu9w@mail.gmail.com \
    --to=zackw@panix.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=libc-alpha@sourceware.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).