[PATCH 1/1] makedevs: set path size to match linux
Michael Conrad
mconrad at intellitree.com
Tue Jun 27 17:18:14 UTC 2017
On 6/27/2017 3:10 AM, Ralf Friedl wrote:
> Michael Conrad wrote:
>> If you ask for large enough allocations on the stack, GCC will
>> secretly give you malloc/free instead, which adds to code size. It
>> might be that 4096 triggers this effect, and perhaps that was the
>> reason for the original small-ish static buffer.
> Do you have a reference for that? I just tried it, and GCC just
> allocates memory from the stack no matter the size. Granted, it is a
> 64-bit system, but I used 0x1000000000000 (281474976710656) which
> should be enough to trigger such a behavior even on a 64-bit system.
> In fact, it is more than a current system can provide either in the
> stack or through malloc.
I guess I'll retract this, unless someone else knows something. I
remember someone warning about this behavior, but I can't find a
reference and I just tested on 32-bit and allocating stack buffers up to
the maximum stack size are all shifting the stack pointer by the size of
the buffer. Declaring a buffer larger than the maximum stack size
results in an instant segfault when the function is called.
It could have been a different compiler, or platform, or maybe a special
flag to gcc. Sorry for the misinformation.
-Mike
More information about the busybox
mailing list