fix(build): a source with a zero byte is refused by its place, with what to do, before its compiler runs #2150
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2150
Loading…
Reference in a new issue
No description provided.
Delete branch "HumanBean/Longshot:zero-byte-source"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
A player's nightly 695 build (Windows, launcher 1.2.0) stopped in Compile with only clang's
code_009.split.c:130717:78: error: extraneous ')' before ';'. The line in the log shows why:The lifted
code_009.c(26 MB) held a zero byte where the(of(_b+_o)belongs. Nothing in the lift, the giantsplitter or the register locals writes one, so the drive or the memory changed the file after it was written. The
player got a compiler error that looked like a Longshot bug, with nothing saying what to do.
compile_one(nx2/build.py) now reads each source it is about to compile and, if it finds a zero byte, refuses itbefore the compiler runs, as one line the launcher shows:
make_game.forget_failed_buildalready forgets the lift when acode_file fails, so "Build again" writes the fileagain: unchanged here.
Read first: the check at the top of
compile_one's compile path,nx2/build.py. It lives insidecompile_onerather than in a helper, so the tests that cutcompile_oneout withast(test_compiler_failure,test_compile_retry_jobs,test_compile_stops_on_exception,test_mem_gate_leases,test_third_party_objects) still run it unchanged.Testing
Tested:
tests/test_compile_zero_byte.pyrunsnx2/build.py's owncompile_one, cut out withast, with a stand-incompiler (no game, no native compiler): a source with a zero byte fails with the error at its line and column, the
compiler never runs, and no object, stamp or cache entry is left; a whole source compiles as before. It is committed
before the fix, so on
mainthe first case fails (the damaged source "compiles"). No tests were run on this PC (theperson I work for runs none here); CI runs them. Not run in the game: the change is in the build, not in anything the
game runs, and a damaged lifted file can't be made in a real build without hand-editing generated output.
Still to test:
merge)
Measurements
Nothing to measure: the game's code is unchanged, and the build only reads each source it compiles once more (
bytes.findover at most ~26 MB, a few milliseconds, against a compile of seconds to minutes), for files not already cached.Risks
A source holding a zero byte on purpose would now be refused: none in
host/,gpu/,third_party/ornx2/(
grep -rlP '\x00'over their C and C++ files finds none), and the lift never writes one. A revert is enough. Playersnotice nothing unless a file is damaged, and then they get a clear message instead of a compiler error.
Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named). (CI: not run on this PC)main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
tests/that reads changed source is updated, not weakened. (none needed: the check is insidecompile_one, so the tests that cut it out need nothing new; to be confirmed by CI)mainand passes here. (written to; to be confirmed by CI on the test-only commit and the head)Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
A player's nightly 695 build stopped on clang's "extraneous ')' before ';'" in code_009.c: the lifted file held a zero byte where a "(" belonged. Nothing in the translation writes one; the drive or the memory changed it after it was written. compile_one now finds it first and says so in the one "error:" line the launcher shows, and make_game still forgets the lift, so the next build writes the file again. Co-Authored-By: Claude Opus 5.5 <[email protected]>Possibly related, for context:
61097efd7447d18c816aThe check moved inside compile_one, so the tests that cut compile_one out with ast run it unchanged; Measurements is one line.
WIP: fix(build): a source with a zero byte is refused by its place, with what to do, before its compiler runsto fix(build): a source with a zero byte is refused by its place, with what to do, before its compiler runs