I've been experiencing some very specific collision/visibility segfaults
in vkquake which are not present in our QuakeSpasm port. Working with
thfr@, brynet@, et al in #openbsd-gaming on Libra.chat to troubleshoot,
I was able to get a fix from upstream:
<https://github.com/Novum/vkQuake/commit/dd72ffbf06d6afb04dfe6a09a92056393f45ef23>
No new release yet, so I've applied that patch on top of vkquake 1.37.0
in -current (see attached) and it builds fine. I don't currently have a
-current dev environment with vulkan support, so I successfully built
and run-tested (no more segfaults) the same 1.37.0 port on
amd64/8.0-stable (also attached.)
I've attached both patches in case we want to backport to -stable. I
personally think this is a good idea because you can't get past the
first couple (few?) levels (segfault when interacting with a specific
wall switch required to proceed.)
Thanks in advance and all feedback welcome,
Morgan
Index: Makefile
===================================================================
RCS file: /cvs/ports/games/vkquake/Makefile,v
diff -u -p -r1.25 Makefile
--- Makefile 20 Nov 2026 20:43:21 -0000 1.25
+++ Makefile 25 Nov 2026 14:27:50 -0000
@@ -4,7 +4,7 @@ PKGNAME = vkquake-${GH_TAGNAME}
GH_ACCOUNT = Novum
GH_PROJECT = vkQuake
GH_TAGNAME = 1.37.0
-REVISION = 1
+REVISION = 2
CATEGORIES = games x11
MAINTAINER = Thomas Frohwein <[email protected]>
Index: patches/patch-Quake_gl_model_c
===================================================================
RCS file: patches/patch-Quake_gl_model_c
diff -N patches/patch-Quake_gl_model_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-Quake_gl_model_c 25 Nov 2026 14:27:50 -0000
@@ -0,0 +1,112 @@
+Fix VSP visibility row overread
+<https://github.com/Novum/vkQuake/commit/dd72ffbf06d6afb04dfe6a09a92056393f45ef23>
+addresses <https://github.com/Novum/vkQuake/issues/1067>
+
+Index: Quake/gl_model.c
+--- Quake/gl_model.c.orig
++++ Quake/gl_model.c
+@@ -296,35 +296,29 @@ mleaf_t *Mod_PointInLeaf (float *p, qmodel_t *model)
+ Mod_DecompressVis
+ ===================
+ */
+-byte *Mod_DecompressVis (byte *in, qmodel_t *model)
++static byte *Mod_DecompressVis (const byte *in, int numvisleafs)
+ {
+- int c;
+- byte *out;
+- byte *outend;
+- int row;
+-
+- row = (model->numleafs + 31) / 8;
+- if (mod_decompressed == NULL || row > mod_decompressed_capacity)
++ const int row = (numvisleafs + 7) / 8;
++ // A BSP row has one bit per world visleaf. Callers also access the last 32-bit word.
++ const int bufsize = row + 3;
++ if (bufsize > mod_decompressed_capacity)
+ {
+- mod_decompressed_capacity = row;
++ mod_decompressed_capacity = bufsize;
+ mod_decompressed = (byte *)Mem_Realloc (mod_decompressed, mod_decompressed_capacity);
+ if (!mod_decompressed)
+ Sys_Error ("Mod_DecompressVis: realloc() failed on %d bytes", mod_decompressed_capacity);
+ }
+- out = mod_decompressed;
+- outend = mod_decompressed + row;
++ byte *out = mod_decompressed;
++ byte *outend = out + row;
++ memset (outend, 0, bufsize - row);
+
+ if (!in)
+ { // no vis info, so make all visible
+- while (row)
+- {
+- *out++ = 0xff;
+- row--;
+- }
++ memset (out, 0xff, row);
+ return mod_decompressed;
+ }
+
+- do
++ while (out < outend)
+ {
+ if (*in)
+ {
+@@ -332,27 +326,11 @@ byte *Mod_DecompressVis (byte *in, qmodel_t *model)
+ continue;
+ }
+
+- c = in[1];
++ const size_t c = q_min (in[1], outend - out);
+ in += 2;
+- if (c > row - (out - mod_decompressed))
+- c = row -
+- (out -
+- mod_decompressed); // now that we're dynamically allocating pvs buffers, we have to be more careful to avoid heap overflows with buggy maps.
+- while (c)
+- {
+- if (out == outend)
+- {
+- if (!model->viswarn)
+- {
+- model->viswarn = true;
+- Con_Warning ("Mod_DecompressVis: output overrun on model \"%s\"\n", model->name);
+- }
+- return mod_decompressed;
+- }
+- *out++ = 0;
+- c--;
+- }
+- } while (out - mod_decompressed < row);
++ memset (out, 0, c);
++ out += c;
++ }
+
+ return mod_decompressed;
+ }
+@@ -366,7 +344,7 @@ byte *Mod_LeafPVS (mleaf_t *leaf, qmodel_t *model)
+ {
+ if (leaf == model->leafs)
+ return Mod_NoVisPVS (model);
+- return Mod_DecompressVis (leaf->compressed_vis, model);
++ return Mod_DecompressVis (leaf->compressed_vis, model->numleafs);
+ }
+
+ /*
+@@ -1483,7 +1461,6 @@ Mod_LoadVisibility
+ */
+ static void Mod_LoadVisibility (qmodel_t *mod, byte *mod_base, lump_t *l)
+ {
+- mod->viswarn = false;
+ if (!l->filelen)
+ {
+ mod->visdata = NULL;
+@@ -2389,7 +2366,7 @@ static void Mod_CheckWaterVis (qmodel_t *mod)
+ continue; // found one of this type already
+ }
+ contentfound |= contenttype;
+- vis = Mod_DecompressVis (leaf->compressed_vis, mod);
++ vis = Mod_DecompressVis (leaf->compressed_vis, numclusters);
+ for (j = 0; j < (numclusters + 7) / 8; j++)
+ {
+ if (vis[j])
Index: patches/patch-Quake_gl_model_h
===================================================================
RCS file: patches/patch-Quake_gl_model_h
diff -N patches/patch-Quake_gl_model_h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-Quake_gl_model_h 25 Nov 2026 14:27:50 -0000
@@ -0,0 +1,15 @@
+Fix VSP visibility row overread
+<https://github.com/Novum/vkQuake/commit/dd72ffbf06d6afb04dfe6a09a92056393f45ef23>
+addresses <https://github.com/Novum/vkQuake/issues/1067>
+
+Index: Quake/gl_model.h
+--- Quake/gl_model.h.orig
++++ Quake/gl_model.h
+@@ -702,7 +702,6 @@ typedef struct qmodel_s
+ char *entities;
+ unsigned int entities_crc; // entities lump CRC16
+
+- qboolean viswarn; // for Mod_DecompressVis()
+ qboolean bogus_tree; // BSP node tree doesn't visit nummodelsurfaces surfaces
+
+ int bspversion;
Index: Makefile
===================================================================
RCS file: /cvs/ports/games/vkquake/Makefile,v
diff -u -p -r1.22 Makefile
--- Makefile 18 Sep 2026 18:15:25 -0000 1.22
+++ Makefile 24 Nov 2026 18:26:57 -0000
@@ -3,12 +3,13 @@ COMMENT = port of Quake 1 using Vulkan i
PKGNAME = vkquake-${GH_TAGNAME}
GH_ACCOUNT = Novum
GH_PROJECT = vkQuake
-GH_TAGNAME = 1.36.0
+GH_TAGNAME = 1.37.0
+REVISION = 2
CATEGORIES = games x11
MAINTAINER = Thomas Frohwein <[email protected]>
-# GPLv2
+# GPLv2+
PERMIT_PACKAGE = Yes
WANTLIB += SDL3 c execinfo m mpg123 ogg pthread vorbis vorbisfile vulkan
@@ -30,6 +31,7 @@ MAKE_FLAGS = bindir=${PREFIX}/share/vkqu
X11BASE=${X11BASE}
USE_GMAKE = Yes
+DEBUG_PACKAGES= ${BUILD_PACKAGES}
NO_TEST = Yes
WRKSRC = ${WRKDIST}/Quake
ALL_TARGET = vkquake
Index: distinfo
===================================================================
RCS file: /cvs/ports/games/vkquake/distinfo,v
diff -u -p -r1.19 distinfo
--- distinfo 18 Sep 2026 18:15:25 -0000 1.19
+++ distinfo 24 Nov 2026 18:26:57 -0000
@@ -1,2 +1,2 @@
-SHA256 (vkQuake-1.36.0.tar.gz) = PdG9jBPpAtucPSFs4GVVLLl139ixsXohtJxUWOuKMG4=
-SIZE (vkQuake-1.36.0.tar.gz) = 23935448
+SHA256 (vkQuake-1.37.0.tar.gz) = lVp3d+6UVpc7Hz6ieNnzs0U4x4jcWTjkKnNPrS4tdho=
+SIZE (vkQuake-1.37.0.tar.gz) = 24052619
Index: patches/patch-Quake_common_make
===================================================================
RCS file: /cvs/ports/games/vkquake/patches/patch-Quake_common_make,v
diff -u -p -r1.8 patch-Quake_common_make
--- patches/patch-Quake_common_make 18 Sep 2026 18:15:25 -0000 1.8
+++ patches/patch-Quake_common_make 24 Nov 2026 18:26:57 -0000
@@ -43,7 +43,7 @@ Index: Quake/common.make
#CFLAGS += $(call CHECK_GCC,-fno-asynchronous-unwind-tables,)
CFLAGS += $(call CHECK_GCC,-fno-ident,)
CMD_STRIP=$(STRIP) $(1)
-@@ -283,7 +280,7 @@ OBJS := strlcat.o \
+@@ -298,7 +295,7 @@ OBJS := strlcat.o \
$(SYSOBJ_SYS) $(SYSOBJ_MAIN)
$(BINTOC_EXE): ../Shaders/bintoc.c
Index: patches/patch-Quake_gl_model_c
===================================================================
RCS file: patches/patch-Quake_gl_model_c
diff -N patches/patch-Quake_gl_model_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-Quake_gl_model_c 24 Nov 2026 18:26:57 -0000
@@ -0,0 +1,112 @@
+Fix VSP visibility row overread
+<https://github.com/Novum/vkQuake/commit/dd72ffbf06d6afb04dfe6a09a92056393f45ef23>
+addresses <https://github.com/Novum/vkQuake/issues/1067>
+
+Index: Quake/gl_model.c
+--- Quake/gl_model.c.orig
++++ Quake/gl_model.c
+@@ -296,35 +296,29 @@ mleaf_t *Mod_PointInLeaf (float *p, qmodel_t *model)
+ Mod_DecompressVis
+ ===================
+ */
+-byte *Mod_DecompressVis (byte *in, qmodel_t *model)
++static byte *Mod_DecompressVis (const byte *in, int numvisleafs)
+ {
+- int c;
+- byte *out;
+- byte *outend;
+- int row;
+-
+- row = (model->numleafs + 31) / 8;
+- if (mod_decompressed == NULL || row > mod_decompressed_capacity)
++ const int row = (numvisleafs + 7) / 8;
++ // A BSP row has one bit per world visleaf. Callers also access the last 32-bit word.
++ const int bufsize = row + 3;
++ if (bufsize > mod_decompressed_capacity)
+ {
+- mod_decompressed_capacity = row;
++ mod_decompressed_capacity = bufsize;
+ mod_decompressed = (byte *)Mem_Realloc (mod_decompressed, mod_decompressed_capacity);
+ if (!mod_decompressed)
+ Sys_Error ("Mod_DecompressVis: realloc() failed on %d bytes", mod_decompressed_capacity);
+ }
+- out = mod_decompressed;
+- outend = mod_decompressed + row;
++ byte *out = mod_decompressed;
++ byte *outend = out + row;
++ memset (outend, 0, bufsize - row);
+
+ if (!in)
+ { // no vis info, so make all visible
+- while (row)
+- {
+- *out++ = 0xff;
+- row--;
+- }
++ memset (out, 0xff, row);
+ return mod_decompressed;
+ }
+
+- do
++ while (out < outend)
+ {
+ if (*in)
+ {
+@@ -332,27 +326,11 @@ byte *Mod_DecompressVis (byte *in, qmodel_t *model)
+ continue;
+ }
+
+- c = in[1];
++ const size_t c = q_min (in[1], outend - out);
+ in += 2;
+- if (c > row - (out - mod_decompressed))
+- c = row -
+- (out -
+- mod_decompressed); // now that we're dynamically allocating pvs buffers, we have to be more careful to avoid heap overflows with buggy maps.
+- while (c)
+- {
+- if (out == outend)
+- {
+- if (!model->viswarn)
+- {
+- model->viswarn = true;
+- Con_Warning ("Mod_DecompressVis: output overrun on model \"%s\"\n", model->name);
+- }
+- return mod_decompressed;
+- }
+- *out++ = 0;
+- c--;
+- }
+- } while (out - mod_decompressed < row);
++ memset (out, 0, c);
++ out += c;
++ }
+
+ return mod_decompressed;
+ }
+@@ -366,7 +344,7 @@ byte *Mod_LeafPVS (mleaf_t *leaf, qmodel_t *model)
+ {
+ if (leaf == model->leafs)
+ return Mod_NoVisPVS (model);
+- return Mod_DecompressVis (leaf->compressed_vis, model);
++ return Mod_DecompressVis (leaf->compressed_vis, model->numleafs);
+ }
+
+ /*
+@@ -1483,7 +1461,6 @@ Mod_LoadVisibility
+ */
+ static void Mod_LoadVisibility (qmodel_t *mod, byte *mod_base, lump_t *l)
+ {
+- mod->viswarn = false;
+ if (!l->filelen)
+ {
+ mod->visdata = NULL;
+@@ -2389,7 +2366,7 @@ static void Mod_CheckWaterVis (qmodel_t *mod)
+ continue; // found one of this type already
+ }
+ contentfound |= contenttype;
+- vis = Mod_DecompressVis (leaf->compressed_vis, mod);
++ vis = Mod_DecompressVis (leaf->compressed_vis, numclusters);
+ for (j = 0; j < (numclusters + 7) / 8; j++)
+ {
+ if (vis[j])
Index: patches/patch-Quake_gl_model_h
===================================================================
RCS file: patches/patch-Quake_gl_model_h
diff -N patches/patch-Quake_gl_model_h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-Quake_gl_model_h 24 Nov 2026 18:26:57 -0000
@@ -0,0 +1,15 @@
+Fix VSP visibility row overread
+<https://github.com/Novum/vkQuake/commit/dd72ffbf06d6afb04dfe6a09a92056393f45ef23>
+addresses <https://github.com/Novum/vkQuake/issues/1067>
+
+Index: Quake/gl_model.h
+--- Quake/gl_model.h.orig
++++ Quake/gl_model.h
+@@ -702,7 +702,6 @@ typedef struct qmodel_s
+ char *entities;
+ unsigned int entities_crc; // entities lump CRC16
+
+- qboolean viswarn; // for Mod_DecompressVis()
+ qboolean bogus_tree; // BSP node tree doesn't visit nummodelsurfaces surfaces
+
+ int bspversion;
Index: pkg/README
===================================================================
RCS file: /cvs/ports/games/vkquake/pkg/README,v
diff -u -p -r1.2 README
--- pkg/README 11 Mar 2022 19:05:09 -0000 1.2
+++ pkg/README 24 Nov 2026 18:26:57 -0000
@@ -23,6 +23,9 @@ ${PREFIX}/share/vkquake/id1/
Note that the filename must be all lower case (e.g. 'pak0.pak') to work with
vkquake.
+Alternatively, you can specify a location of the quake data (the directory that
+*contains* the id1/ subdir) via -basedir argument.
+
Optional - Music / Soundtrack
-----------------------------
The original quake had a great soundtrack by Nine Inch Nails. Unfortunately, the