Commit b48344a
authored
Validate libtorch package architecture during binary validation (#8205)
## Problem
The libtorch branch of `validate_binaries.sh` only downloaded and
unzipped the package, then `exit 0` with no verification:
```bash
if [[ ${MATRIX_PACKAGE_TYPE} == "libtorch" ]]; then
curl "${MATRIX_INSTALLATION}" -o libtorch.zip
unzip libtorch.zip
exit 0
fi
```
So the arch mismatch in pytorch/pytorch#187812 -- where the Windows
x86_64 libtorch package was overwritten by the arm64 build and shipped
Aarch64 binaries under the x64 download URL -- slipped through
validation entirely.
## Fix
After unzip, read the machine field directly from the extracted `c10`
library header (PE on Windows, ELF on Linux, Mach-O on macOS) and fail
validation if it doesn't match the runner architecture. This is shared
by the linux/windows/macos validate workflows, so all are covered.
- Dependency-free: uses the runner's `python` and parses the binary
header directly (no `file(1)`, which isn't reliably present on Windows
runners).
- Skips gracefully if the c10 library or python can't be found.
The upstream packaging fix is pytorch/pytorch#187837; this is the
validation-side guard so a future regression is caught before release
rather than by users.
## Test Plan
Verified header parsing against a real ELF binary and synthetic PE/ELF
headers with arm64 machine fields:
```
real /bin/ls on x86_64 host -> x86_64 (matches, passes)
synthetic AArch64 ELF (e_machine=0xB7) -> arm64 (mismatch on x64 runner, fails)
synthetic ARM64 PE (machine=0xAA64) -> arm64 (mismatch on x64 runner, fails)
```
Confirmed the script still parses: `bash -n
.github/scripts/validate_binaries.sh`.
This change was authored with the assistance of an AI coding assistant
(Claude Code).
---------
Co-authored-by: Andrey Talman <atalman@users.noreply.github.com>1 parent 10e5555 commit b48344a
2 files changed
Lines changed: 80 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
220 | 220 | | |
221 | 221 | | |
222 | 222 | | |
223 | | - | |
224 | | - | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
225 | 231 | | |
226 | 232 | | |
227 | 233 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
0 commit comments