bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: alloca


From: Bruno Haible
Subject: Re: alloca
Date: Sun, 26 Jul 2020 15:34:37 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-186-generic; KDE/5.18.0; x86_64; ; )

Hi Jeffrey,

> All alloca() code should be removed; not just CRAY.
> alloca() is a dangerous compiler builtin.

I disagree: when you use it with bounded allocation size only (e.g. through
the module 'malloca'), there is no danger.

> It is not part of the C language.

Correct.

> It does not convey failure

A plain function entry does not convey failure either.

> and it allows hoping over guard pages.

This is a danger, yes. With bounded allocation size only, there is no
problem.

In gnulib and other GNU code, there are many unbounded alloca() uses,
however. Patches to turn them into bounded alloca() are welcome!

Note that the module 'scratch_buffer' is overkill for these cases:
if you can determine the allocation size ahead, and it is less than 1 KB,
why should the code waste 1 KB of stack space?

Bruno




reply via email to

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