Skip to contentSkip to conversation

man/man3/mallinfo.3: Reduce MAX_ALLOCS

PATCH Applied [email protected] 2 participants 2 messages Aug 16, 2025 Man-pages: manual pages for Linux -- Sections 2, 3, 4, 5, and 7

lore
Share & tools
lore
#0 lore raw

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
index 5e722e38e..0e1deb748 100644
@@ -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
maintainer Applied
#1 lore raw
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.

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
index 5e722e38e..0e1deb748 100644
@@ -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/>