From: "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com>
To: наб <nabijaczleweli@nabijaczleweli.xyz>,
"Alejandro Colomar" <alx.manpages@gmail.com>
Cc: mtk.manpages@gmail.com, linux-man@vger.kernel.org
Subject: Re: [PATCH 2/2] alloca.3: rewrite NOTES
Date: Tue, 24 Aug 2021 11:50:57 +0200 [thread overview]
Message-ID: <d2c606ce-468d-8545-30cc-d8dabeb48296@gmail.com> (raw)
In-Reply-To: <c08c2bb9ccbbc097166f4815f8dea420e5fe1044.1629752426.git.nabijaczleweli@nabijaczleweli.xyz>
Hello Ahelenia
On 8/23/21 11:01 PM, наб wrote:
> This demistifies the internals and removes outdated information
> and needless glibc guts
Some of this patch seems fine, but it does more than I would like to see
in one patch. Some comments below.
> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
> ---
> man3/alloca.3 | 66 ++++++++++++++++-----------------------------------
> 1 file changed, 21 insertions(+), 45 deletions(-)
>
> diff --git a/man3/alloca.3 b/man3/alloca.3
> index 5bceeabe1..133ca6ab3 100644
> --- a/man3/alloca.3
> +++ b/man3/alloca.3
> @@ -84,20 +84,14 @@ T} Thread safety MT-Safe
> .SH CONFORMING TO
> This function is not in POSIX.1.
> .PP
> -There is evidence that the
> .BR alloca ()
> -function appeared in 32V, PWB, PWB.2, 3BSD, and 4BSD.
> -There is a man page for it in 4.3BSD.
> -Linux uses the GNU version.
> +originates from PWB and 32V, and appears in all their derivatives.
The patch subject says "rewrite NOTES", but here you change
the CONFORMING TO. For the record, I think the change is fine;
there was too much info here that isn't really helpful.
But, I would prefer this change as a separate patch, with
a commit message that notes that the CONFORMING TO is
overly complex, so let's simplify.
> .SH NOTES
> The
> .BR alloca ()
> function is machine- and compiler-dependent.
> -For certain applications,
> -its use can improve efficiency compared to the use of
> -.BR malloc (3)
> -plus
> -.BR free (3).
> +Because it allocates from the stack, it's always faster than
> +.BR malloc (3)/ free (3).
Okay.
> In certain cases,
> it can also simplify memory deallocation in applications that use
> .BR longjmp (3)
> @@ -125,51 +119,33 @@ Do not attempt to
> .BR free (3)
> space allocated by
> .BR alloca ()!
> -.SS Notes on the GNU version
> -Normally,
> -.BR gcc (1)
(Removing mention of gcc makes sense...)
> -translates calls to
> +.PP
> +By necessity,
> +.BR alloca ()
> +is a compiler built-in, also known as
> +.BR __builtin_alloca ().
I'm not convinced about this change, or what follows. At the
least, it needs some explanation.
> +By default, modern compilers automatically translate plain
What does "plain" mean here? It is not explained.
> .BR alloca ()
> -with inlined code.
> -This is not done when either the
> +calls, but this is forbidden if
Why lose the piece "with inlined code"?
And why the word "forbidden"? Who forbids it?
> .IR "\-ansi" ,
> .IR "\-std=c89" ,
> .IR "\-std=c99" ,
> -or the
> +or
> .IR "\-std=c11"
Okay.
> -option is given
> -.BR and
> -the header
> -.I <alloca.h>
> -is not included.
> -Otherwise, (without an \-ansi or \-std=c* option) the glibc version of
> -.I <stdlib.h>
> -includes
> +are specified, in which case
> .I <alloca.h>
> -and that contains the lines:
> +is required, lest an actual symbol dependency is emitted.
(That last line seems like a useful addition!)
> .PP
> -.in +4n
> -.EX
> -#ifdef __GNUC__
> -#define alloca(size) __builtin_alloca (size)
> -#endif
> -.EE
> -.in
> -.PP
> -with messy consequences if one has a private version of this function.
> -.PP
> -The fact that the code is inlined means that it is impossible
> -to take the address of this function, or to change its behavior
> -by linking with a different library.
Why remove the preceding piece? This should be clarified in the
commit message.
> -.PP
> -The inlined code often consists of a single instruction adjusting
> -the stack pointer, and does not check for stack overflow.
> -Thus, there is no NULL error return.
Why remove the preceding piece?
> +The fact that
> +.BR alloca ()
> +is a built-in means it is impossible to take its address
> +or to change its behavior by linking with a different library.
> .SH BUGS
> -There is no error indication if the stack frame cannot be extended.
> -(However, after a failed allocation, the program is likely to receive a
> +As it's untestable, there is no error indication if the allocation
It's not clear to me that adding "As it's untestable," really helps
the reader. Why do you think it does? (This should be explained in
the commit message.)
> +would overflow the space available for the stack.
> +(However, the program is likely to receive a
> .B SIGSEGV
> -signal if it attempts to access the unallocated space.)
> +signal if it attempts to access that space.)
> .PP
> On many systems
> .BR alloca ()
My feelings about this patch:
* There's good stuff here, and stuff that I am less sure of.
* This should be *at least* 2 patches, but possibly 3 or 4.
* We need some meaningful commit messages. Your two line commit
message is too vague; think of people some years from now
looking at these changes, and asking: "what was the author's
motivation for these changes?"
Would you be willing to rework this patch in the light of
the above please? Breaking it into a few pieces (if you can)
would make it much easier to wave some pieces through and
discuss the other pieces in detail.
Thanks,
Michael
--
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
next prev parent reply other threads:[~2021-08-24 9:51 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-23 21:01 [PATCH 1/2] strdup.3: drop mention of "the GNU GCC suite" наб
2021-08-23 21:01 ` [PATCH 2/2] alloca.3: rewrite NOTES наб
2021-08-24 9:50 ` Michael Kerrisk (man-pages) [this message]
2021-08-24 10:04 ` G. Branden Robinson
2021-08-24 11:58 ` наб
2021-08-24 10:33 ` Alejandro Colomar (man-pages)
2021-08-24 11:18 ` Alejandro Colomar (man-pages)
2021-08-25 18:21 ` наб
2021-08-24 11:47 ` наб
2021-08-24 9:21 ` [PATCH 1/2] strdup.3: drop mention of "the GNU GCC suite" Michael Kerrisk (man-pages)
2021-08-24 10:28 ` наб
2021-08-24 10:40 ` Alejandro Colomar (man-pages)
2021-09-14 12:40 ` [PATCH v2 0/5] alloca(3) commentary re-write наб
2021-09-14 12:40 ` [PATCH v2 1/5] strdup.3: drop mention of "the GNU GCC suite" наб
2021-09-15 19:49 ` Alejandro Colomar (man-pages)
2021-09-14 12:41 ` [PATCH v2 2/5] alloca.3: clarify origins in CONFORMING TO наб
2021-09-15 19:49 ` Alejandro Colomar (man-pages)
2021-09-14 12:41 ` [PATCH v2 3/5] alloca.3: clarify reasoning for no error return in BUGS наб
2021-09-15 19:42 ` Alejandro Colomar (man-pages)
2021-09-17 20:35 ` наб
2025-10-29 8:42 ` G. Branden Robinson
2025-10-29 10:15 ` Alejandro Colomar
2025-10-29 10:30 ` G. Branden Robinson
2025-10-29 10:58 ` Alejandro Colomar
2025-10-29 11:12 ` G. Branden Robinson
2025-10-29 11:23 ` Alejandro Colomar
2025-10-29 15:22 ` наб
2025-10-29 22:55 ` G. Branden Robinson
2021-09-14 12:41 ` [PATCH v2 4/5] alloca.3: remove GCC faffling from NOTES наб
2021-09-15 19:48 ` Alejandro Colomar (man-pages)
2021-09-17 20:45 ` наб
2021-09-19 19:39 ` Alejandro Colomar (man-pages)
2021-09-14 12:41 ` [PATCH v2 5/5] alloca.3: simplfy malloc(3) suite comparison, note VLAs наб
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=d2c606ce-468d-8545-30cc-d8dabeb48296@gmail.com \
--to=mtk.manpages@gmail.com \
--cc=alx.manpages@gmail.com \
--cc=linux-man@vger.kernel.org \
--cc=nabijaczleweli@nabijaczleweli.xyz \
/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