Skip to content

stat: truncate >32-bit inodes; lift: re-decode missed function entries - #51

Merged
kanapitsas merged 2 commits into
kanapitsas:mainfrom
Zertrox123:fix/stat-inode-and-lift-resync
Nov 20, 2026
Merged

kanapitsas merged 2 commits into
kanapitsas:mainfrom
Zertrox123:fix/stat-inode-and-lift-resync

Conversation

@Zertrox123

Copy link
Copy Markdown
Contributor

Summary

Two small runtime and lifter fixes extracted from the Portal Stories: Mel bring-up that benefit all games:

  • runtime/stat.c: truncate st_ino values wider than 32 bits instead of failing 32-bit stat with EOVERFLOW. Files on macOS's sealed system volume (e.g. /System/Library/Fonts/*) routinely carry 64-bit inodes; guests only treat st_ino as an identifier, and an ignored stat failure left FS_fopen with an uninitialized 64-bit file size (leading to a 1.8 GB OOM).
  • tools/lift.py: add LazyInsns._resync() to re-decode a short image-relative window from a missed function entry when objdump's linear sweep went out of step before it (for example after inline jump tables in non-PIC code sections), while keeping already-decoded instructions.

Testing

  • Added regression checks in tests/filesystem_checks.h (32-bit __xstat on /System/Library/Fonts/Helvetica.ttc) and tests/test_lift.py (LazyInsnsResync).
  • make check and ./build/abi-smoke-ubsan pass on macOS Apple Silicon (223 Python tests, 265 C checks).

Sealed macOS system volumes (such as /System/Library/Fonts) commonly have
64-bit inode numbers. Returning EOVERFLOW from 32-bit stat broke guests that
ignore stat errors when probing system fonts; truncating st_ino to 32 bits
matches how games use it as an opaque identifier.
… out of step

Non-PIC code sections with inline jump tables (such as Bink in Portal Stories:
Mel's valve_avi.so and engine.so) can push objdump's linear sweep out of step
across the next function entry. Add LazyInsns._resync to decode a short
image-relative window from a missed entry while keeping already-decoded
instructions.
@kanapitsas
kanapitsas merged commit fb0ceb0 into kanapitsas:main Nov 20, 2026
3 checks passed
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.

2 participants