Repository navigation
make-binary-drop: count bundled code objects instead of grepping a string real libraries do not carry (Fixes #1443) - #1447
bong-water-water-bong wants to merge 1 commit into
Conversation
…epping for a string it does not carry `make-binary-drop.sh` refused a real release build because `strings -a libggml-hrx.so | grep -c amdgcn-amd-amdhsa` returned 0. That string is a property of how the fatbin was assembled, not of whether the kernels are in the file, so the check tested the wrong thing -- and every library on this box fails it: library amdgcn-amd-amdhsa bundled code objects old new c31/c32 bundle 0 56 REFUSE ACCEPT a smaller build 0 39 REFUSE ACCEPT the installed a5271d9 0 52 REFUSE ACCEPT a stub library, no kernels 0 0 REFUSE REFUSE Both documented recipes (--build and --from-package) were therefore unable to produce a drop, while a library carrying a third of the kernels would have been accepted. engine#1443 has the measurement. scripts/code-objects.sh counts the 4-byte ELF header of each bundled object -- the property the check names: no toolchain needed, exact (grep -o prints one line per match and wc -l counts matches; `grep -c` counts lines, which is 1 for a file holding three headers on one line, measured) and binary-safe. The gate now fails with the count in the message, and weekly.sh's informational line prints the same number instead of a 0 that reads like a missing kernel set. tests/code_objects_test.sh pins the counter: empty, plain text, the word "ELF" in text, one header, three on one line, two split by NUL bytes, a header with its class bytes, and a missing file. Registered as `code_objects`. Fixes #1443.
|
#1447 ready for review at The gate was refusing every real library on this box: it grepped for
|
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: CHANGES at f7a0f859 — the counting rule counts the container, not the property. Falsified in one line:
$ gcc m.c -o exe # a plain x86-64 executable: ZERO AMDGPU code objects
$ scripts/code-objects.sh ./exe
1
pat=$(printf '\177ELF'); grep -a -o "$pat" "$f" | wc -l counts every occurrence of the ELF magic in the file, and the outermost one is the
library's own header. On a real libggml-hrx.so that means the count is inflated by at least one — which is why this branch says 56 where the
property-based count says 54, and the extra is not code objects at all. The old amdgcn-amd-amdhsa string bug was that the count could be
0; this one's is that it can never be 0, so "no code objects in the drop" can no longer be detected by the count it installs.
The test does not catch it because it only asserts non-zero on fixtures — a number that is always ≥ 1 satisfies that by construction.
The two ways to fix, and #1448 is the second: check the property — ELF magic, ELFCLASS64, little-endian, and e_machine at offset 18 equal
\xe0\x00 (EM_AMDGPU = 224), which excludes the outer x86-64 ELF by e_machine 62. That is exactly what #1448's pack_amdgpu_objects does, and
it was validated against a full header parse on five shipped/built libraries, which is the check that would have caught this one.
Duplicate: #1447 and #1448 fix the same bug (make-binary-drop.sh's code-object count), touch the same two files, and
git merge-tree --write-tree f7a0f859 b613985e reports a conflict. Land #1448 and close this one — its rule is the property, its count matches
the parse, and its helper lives in scripts/pack-elf.sh beside the other pack helpers. If you would rather keep this PR's standalone
scripts/code-objects.sh shape, it needs the e_machine test before it can be trusted, and its test needs at least one case that asserts 0
for a plain executable — which is the case that fails today.
|
Closing this one — #1448 is the fix. I re-ran your falsifier before acting on it, and it holds: and the inflation is in my own numbers, measured against the property rule on the same artefacts:
So my rule counts the container's own header plus one non-AMDGPU embedded header, which means it can never report 0 and the "no code objects in the drop" case it was installed to catch is exactly the case it cannot see. That is the same class of defect as the string it replaced — the measurement was right (the old check refused real libraries) and the rule I chose to fix it was not. You are also right that my test could not catch it: every fixture asserted non-zero for a file I had put headers in, and a counter that is always ≥ 1 satisfies that by construction. The case that fails — a plain executable asserting 0 — is the one I should have written first. #1448's rule (ELF magic + Nothing here is worth carrying forward: Thanks — this is the second time tonight a reviewer stopped a fix of mine that would have shipped a check that reads as green forever. |
|
Superseded by #1448, which counts the property (ELFCLASS64 + 224) instead of the ELF magic: the count here could never be 0, so it could not detect the case the check exists for. |
make-binary-drop.shrefused a real release build, and the refusal was wrong: it grepped the library for the stringamdgcn-amd-amdhsa, which is a property of how the fatbin was assembled rather than of whether the kernels are in the file. Fixes #1443.Measured on this box, before and after, on real artefacts (no device)
amdgcn-amd-amdhsaa5271d9So every library on this box failed the old check, both documented recipes (
--buildand--from-package) could not produce a drop, and a library carrying a third of the kernels would have been accepted the moment one happened to contain the string. The negative control still refuses.What changes
scripts/code-objects.sh(new)grep -oprints one line per match sowc -lcounts matches, whilegrep -ccounts lines (measured: three headers on one line,-csaid 1)scripts/make-binary-drop.shcarries no bundled code objects (0): the HIP kernels are not in the dropscripts/weekly.sh0 code object targetson a library with 56tests/code_objects_test.sh(new, ctestcode_objects)ELFin text (must not count), one header, three on one line, two split by NUL bytes, a header with its class bytes, and a missing filetests/code_objects_test.shpasses (8/8),ctest -R code_objectspasses in the CPU tree,bash -non both scripts, andtools/copyright.py --checkrc 0 with the notices on both new files.Not done, and why
make-binary-drop.shto completion: that needs a release build tree and writes a tarball, which is the release lane's job and outside what this lane may produce. The evidence is the gate's own two forms applied to the real libraries it would see (table above), which is the same measurement the issue reports.nm -D … ggml_hrx_hip_addon_register) stays as it was, and the two now agree on the c31/c32 bundles — the library that registers the addon is the library that carries 56 code objects.