ping//Re: [PATCH v2] io:nftw/ftw:fix stack overflow when large nopenfd [BZ #26353]
Xiaoming Ni
nixiaoming@huawei.com
Sat Aug 22 03:27:26 GMT 2020
On 2020/8/22 10:51, Paul Eggert wrote:
> On 8/21/20 7:23 PM, Xiaoming Ni wrote:
>> - data.dirstreams = (struct dir_data **) alloca (data.maxdir
>> + data.dirstreams = (struct dir_data **) malloc (data.maxdir
>> * sizeof (struct dir_data *));
>
> Surely this should call alloca unless data.maxdir is too large, as
> malloc puts pressure on the heap. That's what's done elsewhere in glibc,
> anyway.
The user may run the setrlimit() or unlimit -s command to modify the
stack space limit.
When the user runs the ftw() command, the remaining stack space cannot
be determined.
How do I determine whether data.maxdir is too large for alloca?
malloc puts pressure on the heap, cause ENOMEM
but alloca puts pressure on the stack, cause stack overflow, Worse.
Thanks
Xiaoming Ni
More information about the Libc-alpha
mailing list