Skip to content

qcommon: copy packed VM operands without unaligned loads - #429

Open
msetaro wants to merge 1 commit into
ec-:mainfrom
msetaro:issue/31-vm-upstream
Open

msetaro wants to merge 1 commit into
ec-:mainfrom
msetaro:issue/31-vm-upstream

Conversation

@msetaro

@msetaro msetaro commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Valid QVM startup under GCC UBSan reports an unaligned int32_t load in VM_LoadInstructions. Copy the four operand bytes with the existing CopyLittleLong helper into an int32_t temporary, then retain the existing assignment and instruction advance.

All interpreter and architecture compiler callers use this shared function. No opcode, instruction layout, arithmetic or JIT behavior changes.

Reproduced on upstream f694bbb with a dedicated GCC UBSan build:

make -j8 BUILD_DIR=/tmp/quake3e-vm-ubsan BUILD_CLIENT=0 \
  CC='gcc -fsanitize=undefined' CFLAGS=-fno-omit-frame-pointer
UBSAN_OPTIONS=halt_on_error=1:suppressions=/tmp/zip-only.supp \
  /tmp/quake3e-vm-ubsan/release-linux-x86_64/quake3e.ded.x64 \
  +set fs_basepath /path/to/installed/q3-data \
  +set fs_homepath /tmp/quake3e-vm-home +set dedicated 1 +map q3dm17 +quit

/tmp/zip-only.supp contains only alignment:unzlocal_GetCurrentFileInfoInternal, for the independent ZIP issue in #428. Use a fresh home and installed valid content. Before: exit 1 at vm.c:1181. After: clean startup and exit 0. No game content is included.

The fork's existing GCC UBSan bot smoke passes both Quake 3 and OpenArena map goldens with no alignment suppressions after this fix. GCC x86_64 production symbols pass; all 26 function sections are byte-identical. The assembly-text gate reports only the compiler-generated switch-table name changing from CSWTCH.89 to CSWTCH.90, with no instruction or table-data changes.

Tracked in msetaro#31.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant