public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: Bruno Haible <bruno@clisp.org>,
	Florian Weimer <fweimer@redhat.com>,
	libc-alpha@sourceware.org
Subject: Re: [PATCH 3/3] Misc: Add <sys/cstack.h> and the cstack_* family of functions
Date: Tue, 25 May 2021 09:29:20 -0300	[thread overview]
Message-ID: <e8b5bb19-213c-d1fb-ee18-9a2fe4d99052@linaro.org> (raw)
In-Reply-To: <ed06de94-4221-e1ff-7809-8989ef82f109@cs.ucla.edu>



On 24/05/2021 20:41, Paul Eggert wrote:
> On 5/24/21 12:11 PM, Adhemerval Zanella via Libc-alpha wrote:
> 
>> If this is really a requirement, I think the best options would be to add
>> an extra flag to opt-in.
> 
> Opt-in works for me. Although the GNU apps I help maintain typically don't have nested functions, nested functions are a longstanding GNU C feature and are a good thing to have when you need them.
> 
> Part of the issue here (in case this isn't clear) is that we might want to have a Gnulib version (or even just a copy) of cstack_* to help port GNU apps to other platforms. On these other platforms, mmap might not be the right way to make a stack executable (or might not be needed). I imagine that it'd be better to have this implementation detail done by the cstack_* implementation, than to have each nested-function-using app port this detail by hand.
> 
>> The cstack_t is basically another heap object and I think it should be
>> handled as such.
> 
> I hope that "handled as such" doesn't mean "the user must always manually free it". That is, even if the cstack_t object is on the heap, surely it'd be more convenient for cstack_* users if the object's storage is automatically reclaimed when a thread exits and the object is no longer needed.

The problem is how we go to tie the object lifetime with the thread.
Because if the idea is to provide a different stack, I think extending
the pthread_attr_t with a size and a flag is way more straightforward
than this cstack_t functions. Something like:

  pthread_attr_t attr;
  pthread_attr_init (&attr);
  pthread_attr_setalternatestack_np (262144, PTHREAD_ATTR_NOBOTTOMGUARD);

In this manner the pthread_create will be responsible to allocate and 
deallocate it (on execution ending, pthread_exit, or pthread_cancel).

The issue is how will it would mingle with current pthread_attr stack 
functions, but I think the functionality your are proposing also has
the same issue.

  parent reply	other threads:[~2021-05-25 12:29 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-24 14:58 Bruno Haible
2021-05-24 15:28 ` Bruno Haible
2021-05-25  7:42   ` Florian Weimer
2021-05-24 19:11 ` Adhemerval Zanella
2021-05-24 23:41   ` Paul Eggert
2021-05-25  7:40     ` Florian Weimer
2021-05-25 12:17       ` Adhemerval Zanella
2021-05-25 12:23         ` Florian Weimer
2021-05-25 12:25           ` Adhemerval Zanella
2021-05-25 12:29     ` Adhemerval Zanella [this message]
2021-05-25  8:41 ` Florian Weimer
  -- strict thread matches above, loose matches on Subject: below --
2021-05-20 12:11 [PATCH 0/3] Convenience function for allocating (alternate signal) stacks Florian Weimer
2021-05-20 12:13 ` [PATCH 3/3] Misc: Add <sys/cstack.h> and the cstack_* family of functions Florian Weimer
2021-05-20 12:21   ` Florian Weimer
2021-05-20 12:50   ` Andreas Schwab
2021-05-20 13:14     ` 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=e8b5bb19-213c-d1fb-ee18-9a2fe4d99052@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=bruno@clisp.org \
    --cc=eggert@cs.ucla.edu \
    --cc=fweimer@redhat.com \
    --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).