man/man3/mallinfo.3: Reduce MAX_ALLOCS
PATCH 1/1 man/man3/mallinfo.3: Reduce MAX_ALLOCS
From: "Dr. David Alan Gilbert" <[email protected]>
The current mallinfo2 example segfaults on 64bit Linux. This happens because it builds a large 'alloc' array on the stack, which is currently 2M entries, each of which is a pointer, so hitting 16MB which is more than the default Linux stack ulimit of 8MiB.
Reduce it.
--- man/man3/mallinfo.3 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
man/man3/mallinfo.3 +1 -1
@@ -282,7 +282,7 @@ .SS Program source int main(int argc, char *argv[]) { -#define MAX_ALLOCS 2000000 +#define MAX_ALLOCS 500000 char *alloc[MAX_ALLOCS]; size_t blockSize, numBlocks, freeBegin, freeEnd, freeStep; \&
Signature · 1 line
2.50.1
Quoted 11 lines · On Sat, Aug 16, 2025 at 09:42:52PM +0100, [email protected] wrote:
From: "Dr. David Alan Gilbert" <[email protected]>
The current mallinfo2 example segfaults on 64bit Linux. This happens because it builds a large 'alloc' array on the stack, which is currently 2M entries, each of which is a pointer, so hitting 16MB which is more than the default Linux stack ulimit of 8MiB.
Reduce it.
Signed-off-by Dr. David Alan Gilbert <[email protected]>
Hi David,
I've applied the patch. Thanks!
<https://www.alejandro-colomar.es/src/alx/linux/man-pages/man-pages.git/commit/?h=contrib&id=e7dab53687ed61b451eb1b5a2e46ac251f25c22c>
Have a lovely night!
Alex
Quoted 20 lines
--- man/man3/mallinfo.3 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)man/man3/mallinfo.3 +1
-1@@ -282,7 +282,7 @@ .SS Program source int main(int argc, char *argv[]) { -#define MAX_ALLOCS 2000000 +#define MAX_ALLOCS 500000 char *alloc[MAX_ALLOCS]; size_t blockSize, numBlocks, freeBegin, freeEnd, freeStep; \&Signature · 1 line
2.50.1
Signature · 1 line
<https://www.alejandro-colomar.es/>