Hello porters,

I found this too late for OpenBSD 8.0, but minivmac crashes on macppc.
I don't get a crash on amd64.  cc -fno-strict-overflow prevents the
crash on macppc, so

 - patch the port to use CC and CFLAGS and not strip(1),
 - add -fno-strict-overflow to CFLAGS,
 - put myself as MAINTAINER.

To find the crash in edgb, I needed "make package DEBUG=-g", which
required using CFLAGS and not stripping the debug info.

Looks like a pointer wrapped around NULL, which is undefined behavior
in C.  Our upgrade from clang 19 to 22 would have triggered the crash.
clang-local(1) does -fwrapv so signed integers can wrap.  clang-19
-fwrapv also defined pointer wrap, but 22 doesn't.  lang/clisp had
pointer wrap and added -fno-strict-overflow for 22.

Only a few distros package minivmac, and if their users are on 64-bit
archs, their minivmac might have never crashed.
--gkoehler

Index: Makefile
===================================================================
RCS file: /cvs/ports/emulators/minivmac/Makefile,v
diff -u -p -r1.6 Makefile
--- Makefile    2 Jun 2025 09:14:27 -0000       1.6
+++ Makefile    16 Oct 2026 02:38:12 -0000
@@ -3,7 +3,7 @@ ONLY_FOR_ARCHS =        i386 amd64 powerpc
 COMMENT =              early macintosh emulator
 
 V =                    36.04
-REVISION =             4
+REVISION =             5
 
 DISTNAME =             minivmac-${V}
 
@@ -11,6 +11,8 @@ CATEGORIES =          emulators
 
 HOMEPAGE =             https://gryphel.com/c/minivmac/
 
+MAINTAINER =           George Koehler <[email protected]>
+
 WANTLIB =              X11 c sndio
 
 # GPLv2
@@ -49,11 +51,18 @@ SUFFIX =            -${FLAVOR}
 FULLPKGNAME =          minivmac${SUFFIX}-${V}
 SUBST_VARS =           SUFFIX
 
+# -fno-strict-overflow fixes minivmac-ii crashing after the chime on
+# macppc.  Without this flag, pointer wrap around NULL is undefined
+# and regs.pc_p in src/MINEM68K.c went out of bounds.  Guess that a
+# pointer overflow caused Recalc_PC_Block to set regs.pc_p to
+# 0x40000000 less than the correct value.
+CFLAGS +=              -fno-strict-overflow
+
 post-extract:
        cp ${FILESDIR}/SGLUSNIO.h ${WRKSRC}/src
 
 do-gen:
-       cd ${WRKSRC}; cc setup/tool.c -o setup_t && \
+       cd ${WRKSRC}; ${CC} ${CFLAGS} setup/tool.c -o setup_t && \
                ./setup_t ${SETUP_FLAGS-${MACHINE_ARCH}} ${MODEL} > gen && \
                sh ./gen
 
Index: patches/patch-setup_BLDUTIL3_i
===================================================================
RCS file: /cvs/ports/emulators/minivmac/patches/patch-setup_BLDUTIL3_i,v
diff -u -p -r1.1.1.1 patch-setup_BLDUTIL3_i
--- patches/patch-setup_BLDUTIL3_i      18 Jul 2024 01:58:15 -0000      1.1.1.1
+++ patches/patch-setup_BLDUTIL3_i      16 Oct 2026 02:38:12 -0000
@@ -1,4 +1,4 @@
-- replace hardcoded gcc with cc
+- replace hardcoded gcc with $(CC)
 
 Index: setup/BLDUTIL3.i
 --- setup/BLDUTIL3.i.orig
@@ -8,7 +8,7 @@ Index: setup/BLDUTIL3.i
                case gbk_ide_cyg:
                case gbk_ide_xcd:
 -                      WriteCStrToDestFile("gcc");
-+                      WriteCStrToDestFile("cc");
++                      WriteCStrToDestFile("$(CC)");
                        break;
                case gbk_ide_snc:
                case gbk_ide_ccc:
Index: patches/patch-setup_WRBGCFLS_i
===================================================================
RCS file: /cvs/ports/emulators/minivmac/patches/patch-setup_WRBGCFLS_i,v
diff -u -p -r1.1 patch-setup_WRBGCFLS_i
--- patches/patch-setup_WRBGCFLS_i      24 Jul 2024 01:02:27 -0000      1.1
+++ patches/patch-setup_WRBGCFLS_i      16 Oct 2026 02:38:12 -0000
@@ -1,8 +1,19 @@
+- use CFLAGS
 - add sndio
+- don't run strip
 
 Index: setup/WRBGCFLS.i
 --- setup/WRBGCFLS.i.orig
 +++ setup/WRBGCFLS.i
+@@ -163,7 +163,7 @@ LOCALPROC WriteBgcCOptOptions(void)
+               if (gbk_targfam_lnds == gbo_targfam) {
+                       WriteCStrToDestFile(" -O2");
+               } else {
+-                      WriteCStrToDestFile(" -Os");
++                      WriteCStrToDestFile(" $(CFLAGS)");
+               }
+       } else {
+               WriteCStrToDestFile(" -O0");
 @@ -357,6 +357,8 @@ LOCALPROC WriteBashGccMakeFile(void)
                                        {
                                                WriteCStrToDestFile(" 
-lossaudio");
@@ -12,3 +23,12 @@ Index: setup/WRBGCFLS.i
                                }
  #endif
  #if 0
+@@ -384,7 +386,7 @@ LOCALPROC WriteBashGccMakeFile(void)
+                       WriteBgcCompileLinkCommonOptions();
+                       WriteEndDestFileLn();
+               --DestFileIndent;
+-              if (gbk_dbg_on != gbo_dbg) {
++              if (0 && gbk_dbg_on != gbo_dbg) {
+                       switch (cur_ide) {
+                               case gbk_ide_bgc:
+                                       if ((gbk_targfam_minx == gbo_targfam)
Index: patches/patch-setup_WRMVCFLS_i
===================================================================
RCS file: patches/patch-setup_WRMVCFLS_i
diff -N patches/patch-setup_WRMVCFLS_i
--- patches/patch-setup_WRMVCFLS_i      18 Jul 2024 01:58:15 -0000      1.1.1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,36 +0,0 @@
-- replace hardcoded gcc with cc
-
-Index: setup/WRMVCFLS.i
---- setup/WRMVCFLS.i.orig
-+++ setup/WRMVCFLS.i
-@@ -182,7 +182,7 @@ LOCALPROC DoMVCSrcFileMakeCompileBody(void)
- 
-       WriteBgnDestFileLn();
- 
--      WriteCStrToDestFile("$(my_prefix)gcc -S");
-+      WriteCStrToDestFile("$(my_prefix)cc -S");
-       WritePathArgInMakeCmnd(WriteSrcFileFilePath);
-       WriteCStrToDestFile(" -o");
-       WritePathArgInMakeCmnd(WriteMVCSrcFileAsmPath);
-@@ -204,7 +204,7 @@ LOCALPROC DoMVCSrcFileMakeAsmBody(void)
- {
-       WriteBgnDestFileLn();
- 
--      WriteCStrToDestFile("$(my_prefix)gcc -c");
-+      WriteCStrToDestFile("$(my_prefix)cc -c");
-       WritePathArgInMakeCmnd(WriteMVCSrcFileAsmPath);
-       WriteCStrToDestFile(" -o");
-       WritePathArgInMakeCmnd(WriteSrcFileObjPath);
-@@ -429,10 +429,10 @@ LOCALPROC WriteMVCMakeFile(void)
-                       case gbk_targ_mx11:
-                       case gbk_targ_mi11:
-                       case gbk_targ_mx64:
--                              WriteCStrToDestFile("gcc");
-+                              WriteCStrToDestFile("cc");
-                               break;
-                       default:
--                              WriteCStrToDestFile("$(my_prefix)gcc");
-+                              WriteCStrToDestFile("$(my_prefix)cc");
-                               break;
-               }
-               WriteCStrToDestFile(" \\");

Reply via email to