Repository navigation
Build with -fsigned-char to fix mklev crash on ARM64 - #8
Merged
Merged
Conversation
Jay's mklev marks the end of the room list with croom->hx = -1 in a plain-char field. On ABIs where char is unsigned (Linux aarch64), -1 is 255, so `for(croom=room; croom->hx>0; croom++)` runs past the last room and somex() computes rand() % 0 (SIGFPE) or walks off room[] (SIGSEGV). Simulated with -funsigned-char on x86: mklev crashed on 5/5 seeds; with this change, 50/50 normal levels pass under gcc and clang and the game starts. The flag restores the PDP-11's signed char for every plain-char assumption without touching original or restored source. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # docs/CHANGELOG.md
neuhaus
pushed a commit
to neuhaus/protoHack
that referenced
this pull request
Nov 15, 2026
Build with -fsigned-char to fix mklev crash on ARM64
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug: on ABIs where plain
charis unsigned (Linux aarch64, e.g. Raspberry Pi, Asahi, ARM servers),mklevcrashes on every normal level. macOS on Apple silicon is unaffected, because Apple's ABI keepscharsigned, which is why macOS CI passes.Cause: Jay's
struct mkroom { char lx,hx,ly,hy; }usescroom->hx = -1(src/root/mklev.c:132, "the only goto in hack") as the end-of-rooms sentinel. Unsigned, -1 becomes 255, sofor(croom=room;croom->hx>0;croom++)(:164) runs past the last room, andsomex()computesrand() % 0(SIGFPE) or walks offroom[](SIGSEGV). It's the same bug class as restoHack #15.Fix:
add_compile_options(-fsigned-char), restoring the PDP-11's signedcharfor all of Jay's plain-char assumptions (also e.g.mhp). No source changes;original/untouched.Verification (x86 with
-DCMAKE_C_FLAGS=-funsigned-charto simulate aarch64; not tested on real ARM hardware):mklevnormal levelsNot fixed here (pre-existing, separate):
makemaz()overflowsint stack[200]on some seeds (e.g../mklev x b 30 16→ stack smashing detected), on both signed and unsigned builds.🤖 Generated with Claude Code