WIP: fix(builder): a Windows program's image ends at its FileAlignment, so the nightly attaches its pack #2583
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!2583
Loading…
Reference in a new issue
No description provided.
Delete branch "HumanBean/Longshot:fix/pe-attach-file-alignment"
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
Nightly fd68f82c's Windows job (run 54507) linked
longshot-builder.exeand then failed atdev release attach:lld pads a PE file to its FileAlignment (512 bytes) after the COFF string table. The builder's
.exeis 26,725,888 bytes, but its headers, sections, symbols and string table end at 26,725,593. The 295 zero bytes after them are that padding, so the program looked like it already carried something.image_endnow rounds a PE's end up to its FileAlignment. A FileAlignment that is not a power of two (or a hand-made test file's 0) leaves the end as it was.This is the first nightly with the pack appended after linking (#2557), so no earlier Windows nightly hit it. Linux was not affected: an ELF's section headers end the file.
Read
builder/crates/build-driver/src/sources.rs:image_endand its new test.Testing
Tested: Linux (CachyOS).
longshot-builder.exehere as CI does (scripts/longshot_builder.py build --target windows --profile dist, llvm-mingw 20261104). It came out the same size as the nightly's, 26,725,888 bytes, with 295 bytes past what main'simage_endcounts. A Linux builder from this branch attached a pack to it (dev release attach) and wrote the file at 26,725,888 + pack + 64 bytes. On main, the same step is the nightly's refusal above.a_pe_program_s_padding_after_its_symbols_is_its_imagemodels lld's layout (a section, two COFF symbols, a string table, the padding to 0x200). It fails on main (image_endgives 0x42A, so attach refuses) and passes here. This PR's CI runs it; per this PC's rule, no tests ran here.cargo clippy -p build-driver --all-targetsis clean.Still to test: the next nightly's Windows job attaches and publishes.
Measurements
Nothing to measure: a check on a file's layout.
Risks
Low. A file cut short inside the last 511 bytes of padding now reads as having no pack. It also has no trailer, so it is still a damaged download, which the release's SHA256SUMS catches. Revert to undo.
Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named). (this PR's CI runs it)main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.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
https://claude.ai/code/session_017vw8e1RP1VgcWpgA7Kq6ec
Possibly related, for context:
Closing as a duplicate of #2581, which fixes the same FileAlignment padding and is better: it counts the padding only when every byte of it is zero and in the file, so a download cut short inside the padding is still refused, and it updates builder.md. Measured here too: this PC's dist longshot-builder.exe has 295 zero bytes after its string table, the nightly's (run 54507) is the same size.
Pull request closed