See: https://savannah.gnu.org/bugs/index.php?63844

From 147ae7a47f13c50bf88f4eb6bacca20378a650cc Mon Sep 17 00:00:00 2001
From: "Kirill A. Korinsky" <kirill@korins.ky>
Date: Tue, 1 Aug 2023 13:32:13 +0200
Subject: [PATCH 1/2] disable GBC(t_other) at cleanup on macOS

This call leads to "Caught fatal error [memory may be damaged]"

Issue was introduced at 749f68a1ce25b762c12d3e880a1185a1c3a6a2ec
---
 o/main.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git o/main.c o/main.c
index 3dca37f56..1c1e06701 100755
--- o/main.c
+++ o/main.c
@@ -432,7 +432,11 @@ gcl_cleanup(int gc) {
   if (gc) {
 
     saving_system=TRUE;
+
+/* on macOS it leads to ERROR "Caught fatal error [memory may be damaged]" */
+#ifndef __APPLE__
     GBC(t_other);
+#endif
     saving_system=FALSE;
     
     minimize_image();
-- 
2.41.0


From 0a5170b325a30a2099e943a8454880176441f7e1 Mon Sep 17 00:00:00 2001
From: "Kirill A. Korinsky" <kirill@korins.ky>
Date: Tue, 1 Aug 2023 13:32:38 +0200
Subject: [PATCH 2/2] disable usage vsystem on macOS

Memory allocated by alloca may not survive vfork on macOS,
and man page for alloca suggest to avoid it.

Issue was introduced at 4bbeada542405a01bbf56ce86873f3cd4d9ec9da
---
 h/notcomp.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git h/notcomp.h h/notcomp.h
index f629398c2..bfd17e4d3 100755
--- h/notcomp.h
+++ h/notcomp.h
@@ -364,7 +364,12 @@ extern bool writable_malloc;
 #define prof_block(x) x
 #endif
 
+/* memory allocated by alloca may not survive vfork on macOS */
+#ifdef __APPLE__
+#define psystem(x) prof_block(system(x))
+#else
 #define psystem(x) prof_block(vsystem(x))
+#endif
 #define pfork() prof_block(fork())
 #define pvfork() prof_block(vfork())
 
-- 
2.41.0

