fix(builder): a Windows longshot-builder no longer takes its file's zero padding for a download cut short #2581
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
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!2581
Loading…
Reference in a new issue
No description provided.
Delete branch "pmwork-personal/Longshot:fix/builder-pe-padding"
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
Since #2557 (
fd68f82c), alongshot-builderwith bytes past its program image and no pack trailer refuses to run: ittakes them for a download that did not end. On Windows, every developer build of the builder refuses itself. To see it
on
mainon Windows: build the builder (cargo build --release -p longshot-builder), thendev.py packwith it(
LONGSHOT_BUILD). It stops at once with "What this longshot-builder carries could not be unpacked (the program's fileis cut short or damaged: a download that did not end). Download longshot-builder again." The same happens in
build-driver's own testa_program_with_no_trailer_carries_nothing, which reads the test program's own file.erlo68 saw the same symptom (#2241's description).
The cause: for a PE,
image_endcounts the headers, the sections, and the COFF symbols and their string table. It doesnot count the zeros that llvm-mingw's lld writes after the string table, up to the PE's FileAlignment (512). A
developer's build keeps its COFF symbols, so its file ends with 255 to 462 such zero bytes (measured below). The same
can apply to the shipped Windows builder: the
distprofile strips the debug information but keeps the symbols, and adistbuild on this PC has 226 zero bytes after its string table. Withmain'simage_end,dev release attachrefuses such a program ("it carries something past its image already"). No nightly has run since #2557, so the
release's Windows step has not run this yet.
This change:
image_endalso counts those zeros, up to the next FileAlignment boundary. It does this only when everybyte there is zero and in the file. A byte that is not zero, or padding that the file does not have whole, is still
past the image, so a download cut short is still refused. ELF programs do not change.
Read first:
image_endinbuilder/crates/build-driver/src/sources.rs(the PE branch) and its new tests at the endof the file.
docs/dev/reference/builder.mdgets one sentence on it.Testing
Tested: Windows 11, llvm-mingw, Rust 1.99.1:
cargo test --locked -p build-driver(its own cargo target folder, through the job queue): on the test commit(
fc2c2e90,main's code plus the new tests), 120 passed and 10 failed. Three of the failures are this bug:a_pe_program_s_zero_padding_to_its_file_alignment_carries_nothing(image_end0x431, not 0x600),a_pack_is_attached_to_a_padded_pe_program("it carries something past its image already") anda_program_with_no_trailer_carries_nothing(128734258, not the file's 128734720 bytes). On the fix (c55adf5a), 123passed and 7 failed: all five PE tests pass. The other 7 fail on Windows with and without this change and read no
file this changes:
channel::tests::profile_says_the_folder_and_the_known_keys,modhook::tests::a_context_resolves_the_profile_and_its_game(a path with../../../targetagainst its canonicalform),
folder::tests::a_romfs_folder_is_the_builder_s_only_when_it_made_it,read::tests::a_dump_s_build_takes_no_romfs_folder_of_the_player_s,modhook::tests::the_dev_mod_folders_are_joined_by_the_os_separator,perf::tests::one_sender_at_a_time(os error183, the file already exists) and
sources::tests::each_unpack_marks_its_folders_used. CI runs these tests on Linux.a_pe_program_s_padding_with_a_byte_that_is_not_zero_is_refusedfailsand the other PE tests pass.
cargo clippy --locked -p build-driver --all-targets -- -D warnings: no warnings.cargo fmt --check: clean.main'simage_endstopsdev.py packwith the message above. Thebuilder from this branch makes the pack over the shared base (the game's code lifted and compiled, the game folder
put together). The game does not run this code (it is the builder's check of its own file), so there was no game
run.
tests/run_all.py --strict --changed: 4 passed (test_ship_state_list, byte_compile_tracked, test_mise_build,test_no_release_lookup). The whole suite (
tests/run_all.py --strict, Windows): 791 passed, 19 failed, 48 skipped.None of the 19 reads a file this changes (
--changed). 15 failed the same way onmain(68ab0bc7) on this PC inan earlier run: test_auto_handheld, test_builder_channel, test_coverage_run, test_dev_ab, test_dev_build,
test_dev_migrate, test_float_add_subgroup, test_game_menu_mouse_buttons, test_input_movie, test_job_queue,
test_oot_menu_mouse, test_pads_after_menu, test_parity_gates, test_run_all_mingw and test_sampler_admission (its "id
concurrent" case, also alone). test_lifter, test_fsr3fi_hud_layer and test_fsr3fi_hudless_colour need
llvm-mcandglslang, which are not on this PC's PATH (--strictfails them). test_invalidate_vcore timed out with 16 checksat once and passes alone.
Still to test:
dev release attachappends the pack to thedistprogram and
longshot_builder.py checkpasses (by hand, watching the run).Measurements
Verdict: a Windows developer build of
longshot-builderruns again; nothing to measure for speed (one check of thebuilder's own file at its start).
Setup: Windows 11, llvm-mingw's lld, Rust 1.99.1; the bytes after the COFF string table in each program, read from its
headers.
fd68f82cc55adf5acargo test -p build-driver, the five PE testsdev.py packwith the branch's own builderbuild-driver's tests): zeros after the string tablereleasebuilder: zeros after the string tabledistbuilder: zeros after the string tableRisks
What could break: a PE whose file ends with up to 511 zero bytes after its image now counts them as its image. Those
bytes can only be zero, so no carried pack (which starts with its magic) is taken into the image, and a release
program with a pack reads its pack as before (
a_pack_is_attached_to_a_padded_pe_programchecks both a padded programand one whose string table ends the file). A revert brings the refusal back. Players notice nothing: a released
builder that ran before runs the same.
Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.tests/that reads changed source is updated, not weakened. (test_no_release_lookup andtest_ship_state_list read
sources.rs; both pass unchanged, so neither needs an update.)Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.Co-Authored-By: Claude Opus 5.5 [email protected]
🤖 Generated with Claude Code
Tested in game: Windows 11, llvm-mingw, Rust 1.99.1: longshot-builder built from this branch (release profile) built the game as a pack over the shared base (dev.py pack: the game's code lifted and compiled, the game folder put together). With main's image_end the same builder stops at once with 'cut short or damaged'. The game does not run this code (the builder's check of its own file), so the game was not started.
c55adf5ac934f90a1b40