bug-gnulib
[Top][All Lists]
Advanced

[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.

Attachment: 0001-glob-use-scratch_buffer-for-internal-glob-dirname.patch
Description: Text Data

Attachment: 0002-glob-use-scratch_buffer-for-GLOB_BRACE.patch
Description: Text Data

Attachment: 0003-glob-use-scratch_buffer-for-glob_in_dir-GLOBPAT_NONE.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]