From ffdcff80ba8d0e78c1203f3d24894dff4d8b2efe Mon Sep 17 00:00:00 2001 From: Josh Davies Date: Tue, 30 Sep 2025 13:22:24 +0100 Subject: [PATCH 1/2] fix: avoid hang in tform when threads fail a memory allocation Calling Error1 while holding ErrorMessageLock causes a hang in Terminate, when the thread attempts to take the long a second time. Use MesPrint to print the error instead. --- sources/tools.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/sources/tools.c b/sources/tools.c index cffa3491..eb67fe62 100644 --- a/sources/tools.c +++ b/sources/tools.c @@ -2226,7 +2226,6 @@ void *Malloc1(LONG size, const char *messageifwrong) char *t, *u; int i; LOCK(MallocLock); -/* MLOCK(ErrorMessageLock); */ if ( size == 0 ) { MesPrint("%wAsking for 0 bytes in Malloc1"); } @@ -2244,13 +2243,10 @@ void *Malloc1(LONG size, const char *messageifwrong) MLOCK(ErrorMessageLock); #endif MesPrint("Attempted to allocate %l bytes.", size); - Error1("No memory while allocating ",(UBYTE *)messageifwrong); + MesPrint("@No memory while allocating %s", (UBYTE *)messageifwrong); #ifndef MALLOCDEBUG MUNLOCK(ErrorMessageLock); #else -/* MUNLOCK(ErrorMessageLock); */ -#endif -#ifdef MALLOCDEBUG UNLOCK(MallocLock); #endif Terminate(-1); From fd84e567e73235e0e1f5a2b95ca017dc5e6fd330 Mon Sep 17 00:00:00 2001 From: Josh Davies Date: Tue, 30 Sep 2025 15:06:45 +0100 Subject: [PATCH 2/2] test: fix test for Issue508 on some systems This test fails on Fedora 42 with a ulimit of 8000000, though it passes on Ubuntu 24.04. Provide a bit more space, but still an insufficient amount for the memory leak being tested. --- check/fixes.frm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check/fixes.frm b/check/fixes.frm index 3d7c84b8..334e5a92 100644 --- a/check/fixes.frm +++ b/check/fixes.frm @@ -2983,7 +2983,7 @@ id g(N?) = 1; print; .end #require linux? -#ulimit -v 8_000_000 +#ulimit -v 8_200_000 # We assume more memory than a 32bit system can provide #require wordsize >= 4 assert succeeded?