shithub: front

Download patch

ref: 20780e694e13d767f637e1e27961b00d5cbe2607
parent: b4c9aaa36b2a5baa6e17d2a60cfbda16cb87d251
author: Ori Bernstein <ori@eigenstate.org>
date: Wed Jul 16 15:41:21 EDT 2025

libc: lift limit on pool sizes

Machines can have a lot of ram these days; we should
allow programs to use it. This fixes some memory hungry
things like indexing the linux git repo.

--- a/sys/src/libc/port/malloc.c
+++ b/sys/src/libc/port/malloc.c
@@ -21,7 +21,7 @@
 
 static Pool sbrkmem = {
 	.name=		"sbrkmem",
-	.maxsize=	(3840UL-1)*1024*1024,	/* up to ~0xf0000000 */
+	.maxsize=	(intptr)~0, /* maximum signed size we can address */
 	.minarena=	4*1024,
 	.quantum=	32,
 	.alloc=		sbrkalloc,
--- a/sys/src/libc/port/pool.c
+++ b/sys/src/libc/port/pool.c
@@ -555,7 +555,7 @@
 	Alloc *b;
 
 	LOG(p, "newarena %lud\n", asize);
-	if(p->cursize+asize > p->maxsize) {
+	if(asize > p->maxsize || p->cursize > p->maxsize - asize) {
 		if(poolcompactl(p) == 0){
 			LOG(p, "pool too big: %llud+%lud > %llud\n",
 				(uvlong)p->cursize, asize, (uvlong)p->maxsize);
--