[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 0/8] Remove alloca usage from glob
From: |
Paul Eggert |
Subject: |
Re: [PATCH 0/8] Remove alloca usage from glob |
Date: |
Wed, 13 Jan 2021 11:36:31 -0800 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 |
On 1/5/21 10:58 AM, Adhemerval Zanella wrote:
The idea of removing the alloca allows a slight better code generation,
simplifies the boilerplate code to avoid the unbounded alloca usage,
and it plays better with security compiler mitigation tools (such as the
ones for stack clash).
Instead of complicating dynarray by adding char_array stuff, I suggest
adding any primitives just to glob for now, as it's not clear that
they're generally useful.
I do see a problem with the proposed patch set, in that it creates
several different dynarrays when glob really needs only one or two. The
existing code is full of memory-allocation gotchas and would be
simplified if it treated the memory it allocates as a first-class part
of the problem rather than as some sort of cranky subsidiary that needs
to be babied and its diaper changed at random intervals.
Attached is a draft set of patches against Gnulib commit
6a00fdb4bb105697aa27ba97ef7ec33287790ad3 which gives a hint about the
sort of thing that I mean here. This patch set is not complete (it does
only the equivalent of the first four of the patches you proposed) and
it's not exactly the form that I want, so I haven't installed it into
Gnulib. However, I hope it shows the sort of thing I have in mind. So
far, it's needed only one scratch buffer.
In this patch set, glob.c continues to use scratch_buffer.h because
scratch buffers are good enough for all the changes needed so far. I
suppose dynarrays will be helpful for later patches and that we can
switch to them as needed, but I wanted to focus on the actual problem
first rather than worrying about scratch buffers vs dynarrays.
0001-glob-use-scratch_buffer-for-internal-glob-dirname.patch
Description: Text Data
0002-glob-use-scratch_buffer-for-GLOB_BRACE.patch
Description: Text Data
0003-glob-use-scratch_buffer-for-glob_in_dir-GLOBPAT_NONE.patch
Description: Text Data
- [PATCH 0/8] Remove alloca usage from glob, Adhemerval Zanella, 2021/01/05
- [PATCH 1/8] malloc: Add specialized dynarray for C strings, Adhemerval Zanella, 2021/01/05
- [PATCH 3/8] posix: Remove alloca usage for GLOB_BRACE on glob, Adhemerval Zanella, 2021/01/05
- [PATCH 4/8] posix: Remove alloca usage on glob dirname, Adhemerval Zanella, 2021/01/05
- [PATCH 2/8] posix: Use char_array for internal glob dirname, Adhemerval Zanella, 2021/01/05
- [PATCH 6/8] posix: Remove alloca usage on glob user_name, Adhemerval Zanella, 2021/01/05
- [PATCH 5/8] posix: Use dynarray for globname in glob, Adhemerval Zanella, 2021/01/05
- [PATCH 7/8] posix: Use char_array for home_dir in glob, Adhemerval Zanella, 2021/01/05
- [PATCH 8/8] posix: Remove all alloca usage in glob, Adhemerval Zanella, 2021/01/05
- Re: [PATCH 0/8] Remove alloca usage from glob,
Paul Eggert <=