Re: [PATCH 1/6] posix: Use malloc instead of alloca for the glob directory name

Collin Funk <[email protected]> Wed, 05 Aug 2026 18:25:18 -0700
Newsgroups gmane.comp.lib.glibc.alpha
Message-ID <[email protected]>
Adhemerval Zanella <[email protected]> writes:

> Use malloc unconditionally instead.  These are one-off allocations
> whose cost is dwarfed by the readdir and fnmatch work that follows.
>
> The amount of stack this can take is not bounded by these calls alone,
> glob recursively calls itself per pattern component, and each call
> starts a fresh alloca budget.
>
> Checked on x86_64-linux-gnu, aarch64-linux-gnu, and i686-linux-gnu.
> ---
>  posix/glob.c | 54 ++++++++++++++++++----------------------------------
>  1 file changed, 19 insertions(+), 35 deletions(-)

This one looks good to me.

Reviewed-by: Collin Funk <[email protected]>

Collin