public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: Tadeus Prastowo <0x66726565@gmail.com>
Cc: "libc-help@sourceware.org" <libc-help@sourceware.org>,
	Florian Weimer <fweimer@redhat.com>
Subject: Re: raise() marked __leaf__ is not C-compliant?
Date: Wed, 28 Oct 2020 14:34:30 -0300	[thread overview]
Message-ID: <76680377-32fb-bf34-5c1e-2dc63d1485c7@linaro.org> (raw)
In-Reply-To: <CAA1Ytms1KHTn9n4K2aUsovXb-CZEFUVudLMOJ6EqvK5Omcf5dQ@mail.gmail.com>



On 28/10/2020 10:19, Tadeus Prastowo wrote:
> On Wed, Oct 28, 2020 at 12:53 PM Adhemerval Zanella
> <adhemerval.zanella@linaro.org> wrote:
>>
>> On 28/10/2020 04:33, Tadeus Prastowo wrote:
>>>
>>> I meant to say: Glibc-2.30 raise() definitely runs a signal handler,
>>> and the signal handler can be defined in the current compilation unit
>>> to use static variables.  So, unless the C standard says that
>>> accessing a non-volatile object with static storage duration from
>>> within a signal handler that is called synchronously using raise() on
>>> a normal execution path is an undefined behavior, the marking of
>>> raise() with __leaf__ makes raise() non-compliant with the C standard.
>>>
>>>> May I know your opinion, please?
>>
>> The sentence "raise() definitely runs a signal handler" is not really
>> valid in a portable sense. Afaik neither C nor POSIX states which signals
>> should be delivered synchronously or asynchronously (although some do
>> only make sense to be delivered synchronously such as SIGSEGV).
>>
>> However, Linux does ran some signals synchronously and I agree that using
>> leaf attribute is incorrect and lead to this kind of problems. My point is
>> to be fully portable, you need to assume any signal might be delivered
>> asynchronously (and C standard specifies the volatile sig_atomic_t for
>> such cases).
> 
> Thank you for your response.
> 
> However, C, including C99, C11, and the latest C18 [1], says: "If a
> signal handler is called, the raise function shall not return until
> after the signal handler does."  And, POSIX [2] says: "If a signal
> handler is called, the raise() function shall not return until after
> the signal handler does."  So, the sentence "raise() definitely runs a
> signal handler" is valid in a portable sense as required by the
> standards, no?

My understanding is it allows synchronous signals, not enforce it;
and if the signal is synchronous then it should complete prior hand.

> 
> [1] Page 195 of
> https://web.archive.org/web/20181230041359/http://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf
> [2] The raise section of Chapter 3 "System Interfaces" of IEEE
> Standard for Information Technology---POSIX, Volume 2 "System
> Interfaces", Issue 7.
> 

  reply	other threads:[~2020-10-28 17:34 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-27 16:57 Tadeus Prastowo
2020-10-27 18:50 ` Adhemerval Zanella
2020-10-28  5:47   ` Tadeus Prastowo
2020-10-28  6:13     ` Tadeus Prastowo
2020-10-28  7:33       ` Tadeus Prastowo
2020-10-28 11:53         ` Adhemerval Zanella
2020-10-28 13:19           ` Tadeus Prastowo
2020-10-28 17:34             ` Adhemerval Zanella [this message]
2020-10-28 19:23               ` Tadeus Prastowo
2020-10-28 20:17                 ` Adhemerval Zanella
2020-10-29  7:50                   ` Tadeus Prastowo
2020-10-28  8:21 ` Florian Weimer
2020-10-28 12:58   ` Tadeus Prastowo
2020-10-28 17:16     ` Tadeus Prastowo

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=76680377-32fb-bf34-5c1e-2dc63d1485c7@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=0x66726565@gmail.com \
    --cc=fweimer@redhat.com \
    --cc=libc-help@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).