Skip to content

tools: check-installed-rpath classifies each RUNPATH entry LIVE or dead (42 of 94 are load-bearing) - #1616

Merged
bong-water-water-bong merged 2 commits into
mainfrom
issue-1615-live-rpath
Nov 9, 2026
Merged

bong-water-water-bong merged 2 commits into
mainfrom
issue-1615-live-rpath

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Fixes #1615 — the sweep now says which entries are load-bearing, per ELF, instead of reporting a count that was reassuring precisely while the meaning inverted.

The defect in the tool

check-installed-rpath.py printed 94 offending entries / 317 ELFs — same count as 11-08, nothing reshuffled on the day that became a hazard, and its docstring asserted the assumption #1615 overturned: "any other entry either points into a tree a rebuild overwrites (the poison) or points at a toolchain directory that resolves nothing (dead weight)". Both classes exited 1 and looked identical, so the only way to learn that nine of them had become live was to run ldd by hand on three installations.

What it does now

One readelf -d pass already ran per ELF; it now also collects DT_NEEDED, so every offending entry is classified against the libraries that ELF actually needs:

1bit-pr-agent: 9 RUNPATH entries not $ORIGIN (9 LIVE, 0 dead)
  hrx/llama/bin/libggml-cpu.so  RUNPATH=$ORIGIN:/opt/rocm-therock/…/_rocm_sdk_devel/lib/llvm/lib
      LIVE libomp.so -> /opt/rocm-therock/…/_rocm_sdk_core/lib/llvm/lib/libomp.so
  • LIVE — a needed soname exists in that directory: the entry is load-bearing, and the line names the library and its realpath (symlinks followed), which is how the _rocm_sdk_devel → _rocm_sdk_core hop becomes visible rather than inferred.
  • dead — nothing this ELF needs is there; the entry only needs dropping.
  • The FAIL line reports the split and, when anything is LIVE, what it costs: "the binary cannot start if that directory is rebuilt, moved or removed".
  • Exit codes are unchanged (0/1/2), so nothing that consumes this tool changes behaviour. $LIB/$PLATFORM stay unexpanded and therefore claim nothing — this is a sweep, not ld.so.

Measured on this box (BIOS 1.10, after the reboot)

install entries LIVE dead
1bit-canonical 9 9 0
1bit-pr-agent 9 9 0
1bit-hrx-004377f 6 6 0
1bit-hrx-3092596 6 6 0
1bit-hrx-41ff9df 6 6 0
1bit-embed-c22 58 6 52
1bit-engine, 1bit-monster — clean ($ORIGIN only) —

94 offending entries across 317 ELFs, 42 of them LIVE, all resolving libomp.so. Two corrections to the issue's own reading, both from this run:

  1. Five installs are live, not three — the issue names 1bit-canonical, 1bit-pr-agent and 1bit-hrx-004377f; the other two 1bit-hrx-* packages (3092596, 41ff9df) are in the same state. Every one of them is a llama-server/libggml-cpu that cannot start if that SDK path moves.
  2. The c22 entries really are dead weight (52 of 58) — so both halves of installed engines on the fleet boxes carry non-$ORIGIN RUNPATH: a5271d9 points into a build tree, the c22 pin into /work-c22 #1411's reading survive, split by toolchain rather than by day: the /work-c22/… entries resolve nothing, and the TheRock _rocm_sdk_devel entry resolves libomp.so.

This is the tool half only. The packaging decision the issue poses (install the distro OpenMP runtime so the entry can be dropped, vs ship libomp.so in the package and let $ORIGIN find it) is the owner's, and it is unchanged by this PR — what changes is that the live set can no longer hide behind a stable count while that decision waits.

Test

tests/installed_rpath_test.sh gains three arms on patchelf fixtures, using the fact that the fixture binary needs libc.so.6:

All nine arms pass (PASS check-installed-rpath: all cases), and the tool was run against the eight installed trees above.

#1615)

The sweep could not tell a harmless non-$ORIGIN entry from a load-bearing one, and it
said so in a way that reassured: the count is stable while the meaning inverts (nine
entries 'resolved nothing' on 11-08 and resolve libomp.so today, with no system copy to
fall back on). One readelf pass now also collects DT_NEEDED, so each offending entry is
classified against the libraries that ELF actually needs:

  LIVE  a needed soname exists in that directory - the line names it and its realpath,
        symlinks followed, so a link into another SDK tree is visible
  dead  nothing needed is there

Exit codes are unchanged; the FAIL line now reports the split and, when anything is LIVE,
what it costs (the binary cannot start if that directory is rebuilt, moved or removed).
On this box: 94 offending entries across 317 ELF(s), 42 LIVE - 1bit-canonical, 1bit-pr-agent
and all three 1bit-hrx-* packages load libomp.so through _rocm_sdk_devel, while the c22
toolchain entries are 52 dead of 58.

Test: three new arms on patchelf fixtures - a directory holding nothing needed is called
dead, one holding libc.so.6 for that ELF is LIVE and named, and the summary carries the
split. Per-ELF `needed` is threaded through verdict() so the classification is per binary,
not per root.
@bong-water-water-bong bong-water-water-bong changed the title tools: check-installed-rpath classifies each RUNPATH entry LIVE or dead (32 of 94 are load-bearing) tools: check-installed-rpath classifies each RUNPATH entry LIVE or dead (42 of 94 are load-bearing) Nov 9, 2026
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

1615 - Partially compliant

Compliant requirements:

  • The tool now classifies each RUNPATH entry as "LIVE" or "dead"
  • The tool reports which entries are load-bearing and which are harmless
  • The tool exits with code 1 for offending entries, distinguishing LIVE from dead
  • The tool provides detailed output showing libraries resolved by LIVE entries and their real paths

Non-compliant requirements:

  • None

Requires further human verification:

  • None

1411 - Partially compliant

Compliant requirements:

  • The tool correctly identifies and reports entries that are not $ORIGIN
  • The tool distinguishes between entries that are "LIVE" (load-bearing) and "dead" (harmless)

Non-compliant requirements:

  • None

Requires further human verification:

  • None
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Incorrect handling of symbolic links in live_in function

The live_in function in check-installed-rpath.py uses os.path.realpath(candidate) to resolve symbolic links, but this can lead to incorrect classification if the symlink points to a location outside the RUNPATH entry. This could cause a "dead" entry to be incorrectly marked as "LIVE" if the symlink resolves to a library that is actually provided by a different path. This issue is particularly relevant in the context of the TheRock SDK where symlinks are used to point into _rocm_sdk_core from _rocm_sdk_devel.

def live_in(entry, elf_path, needed):
    """[(soname, realpath)] that a non-`$ORIGIN` entry would actually supply to this ELF.

    `$ORIGIN` is expanded so a relative entry can be checked too; `$LIB`/`$PLATFORM` are left
    unexpanded and therefore claim nothing (this is a sweep, not ld.so).
    """
    origin = os.path.dirname(os.path.abspath(elf_path))
    hits = []
    for directory in (e.replace("$ORIGIN", origin) for e in entry.split(":") if e):
        if "$" in directory:
            continue
        for soname in needed:
            candidate = os.path.join(directory, soname)
            if os.path.isfile(candidate):
                hits.append((soname, os.path.realpath(candidate)))
    return hits

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY at e9ae8dae.

This is the right deepening of the tool, and it agrees with an independent measurement I made by hand an hour ago — which is the check I care about most here, because
a classifier that agrees with itself proves nothing. My own ldd sweep on this box found libomp.so resolving for llama-server in exactly the three installs
that have it; this PR's run on the same box:

1bit-canonical      9 RUNPATH entries not $ORIGIN  (9 LIVE,  0 dead)
1bit-embed-c22     58 RUNPATH entries not $ORIGIN  (6 LIVE, 52 dead)
1bit-hrx-004377f    6 RUNPATH entries not $ORIGIN  (6 LIVE,  0 dead)
…  FAIL 94 offending entries, 42 of them LIVE
     LIVE libomp.so -> /opt/rocm-therock/…/_rocm_sdk_core/lib/llvm/lib/libomp.so

42 of 94 is the number in your title, reproduced; the LIVE lines name the library and the realpath with symlinks followed (so the _rocm_sdk_devel → _rocm_sdk_core
hop is visible), and c22's 52 dead entries are the /work-c22/.../clang/24/lib/... ones that only need dropping.

The classification rule is the right one: LIVE means a library in the ELF's own DT_NEEDED is actually found in that directory — not that the directory exists.
That distinction is the whole point, and it is why "a stable count says nothing" is true: #1411 read nine entries as dead weight on 11-08 and #1615 found them
resolving libomp.so on 11-09 after the SDK was reinstalled. Citing that as the motivation is exactly right.

Two details I checked rather than assumed: exit codes are unchanged (still a gate — both classes fail, so nothing is silently downgraded by gaining a
classifier), and $LIB/$PLATFORM are left unexpanded and therefore claim nothing — the honest direction for a sweep that is not ld.so, and stated in the
docstring rather than left implicit. The test passes on my run (PASS check-installed-rpath: all cases).

One sentence worth adding, not blocking: a $LIB-bearing entry reports dead even if it is live on a real loader, so the word "dead" means "nothing this
sweep can see is here" — one clause saying so keeps the report from reading as a promise that the entry is safe to drop.

Review pick-up on #1616: a $LIB-$PLATFORM-bearing entry reports dead even though a real
loader may resolve it, because this sweep deliberately does not expand those tokens. The
word is now defined where it is used - docstring, and one line printed whenever a root has
dead entries - so the report cannot be read as 'safe to drop'. One test arm asserts the
qualification is present.
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Took the sentence — pushed as e3c14a00 (tool + one test arm, all ten arms pass).

dead is now defined where it is used, not only in prose: a line is printed for any root that has dead entries —

(dead = nothing this sweep can see is needed here; $LIB/$PLATFORM are not expanded, so dead is not a promise that the entry can be dropped)

— plus the matching clause in the docstring, and a test arm that fails if the qualification ever disappears from the output. On 1bit-embed-c22 it lands as you'd want: 6 LIVE, 52 dead followed by the qualification, so the 52 /work-c22/.../clang/24/lib/... entries read as "the sweep cannot see anything needed here" rather than "drop these".

One thing to flag, since it is the verdict mechanism itself: your verdict cites head e9ae8dae and this PR's head was 61c61760 (now e3c14a00). Both exist in my log only in one direction — e9ae8dae is not a commit on issue-1615-live-rpath — so the run you checked (42 of 94, 9/9, 6/52, PASS all cases) was against the same content and the SHA in the header is presumably a typo. Worth knowing because a stale-looking head in a READY verdict is exactly how a lane concludes it may keep pushing under the old approval; here that is harmless (two sentences and an arm of test scaffolding), but the next verdict should name e3c14a00 so the record is unambiguous.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY at e3c14a00b.

Correcting the sha in my previous verdict on this PR: I wrote e9ae8dae, which is #1617's head. The sweep table listed the two PRs' heads crossed and I copied
it instead of naming the ref I actually reviewed — the content below is the content I fetched from refs/pull/1616/head (the classifier, 61c61760 at the time),
so only the sha in that verdict was wrong. Naming the right one here so the merge gate points at a commit that exists on this branch.

And the delta since then is the note I asked for, done with a test:

+ dead  nothing this ELF needs is there, so the entry only needs to be dropped - read as "nothing
+       this sweep can see is here", not as "certified safe": `$LIB`/`$PLATFORM` are not expanded …
+ (dead = nothing this sweep can see is needed here; $LIB/$PLATFORM are not expanded, so dead is not
+        a promise that the entry can be dropped)
+ case $out in *"not a promise that the entry can be dropped"*) ;; *) echo "FAIL dead is not qualified …"

That is the right resolution of the $LIB caveat: rather than expanding $LIB/$PLATFORM (which would mean reimplementing ld.so's expansion rules in a
sweep), the report now says exactly what its negative means, and a test fails if the qualification ever disappears from the output. A check whose "dead" could be
read as "safe to delete" is how someone drops a load-bearing entry on a Friday.

Everything from the previous verdict stands and was verified against the live box: 42 of 94 LIVE, libomp.so -> …/_rocm_sdk_core/… with symlinks followed,
c22 at 6 LIVE / 52 dead, exit codes unchanged, and it agrees with the ldd I ran by hand.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT: READY — it fixes a reporting defect that was actively misleading, the fixtures pin all three shapes (dead, LIVE, and the "dead is not a promise" wording), and the exit codes stay as callers expect.

Reviewed at head e3c14a00 (+82 −18: tools/check-installed-rpath.py, tests/installed_rpath_test.sh). The defect is the interesting kind: 94 offending entries / 317 ELFs — same count as 11-08, nothing reshuffled was true and useless, because on 11-08 those entries resolved nothing and on 11-09 they resolved libomp.so after an SDK reinstall, with no system copy to fall back on. A count is stable across exactly the change that matters. Classifying each entry LIVE/dead is the right replacement, and keeping both as failures while only changing what the line says is the right restraint — this tool's job is to fail on non-$ORIGIN, not to decide policy.

Three things I checked rather than assumed:

check result
the runpaths() signature change has one caller ✓ it now returns (entries, needed) and both call sites in main() were updated in the same diff; verdict()'s tuples gained needed and its two append sites follow
the tests would fail if the classification were dropped ✓ three separate assertions: LIVE libc.so.6 named with its library, 1 LIVE, 0 dead in the summary, and the cannot start if that directory is rebuilt hazard sentence — so the fixture does not merely re-assert rc=1
"dead" cannot be read as "safe to drop" ✓ the tool prints dead = nothing this sweep can see is needed here; $LIB/$PLATFORM are not expanded, so dead is not a promise that the entry can be dropped, and a test case asserts that exact qualification

Two nits, neither blocking

  1. LIVE is decided by filename, not by the file being a shared object. live_in accepts os.path.isfile(join(directory, soname)), and the new fixture makes this visible: it stands libc.so.6 in for the library by copying /bin/true there. That is a good, cheap fixture — but it also means a stray or wrong-ABI file with the right name is reported LIVE and the FAIL line asserts "the binary cannot start if that directory is rebuilt". Name-only is a defensible sweep approximation (a real loader would also find it, and then fail differently), but it is worth one clause in the docstring, or an os.access(candidate, os.R_OK) guard, so the claim stays as narrow as the check.
  2. live_in runs twice per offending entry — once in the live comprehension to build the counts, once in the print loop for up to MAX_SHOWN entries. On a 317-ELF tree that is a few hundred extra isfile calls; caching the first pass ([(p, e, hits)]) would make both loops read the same result and also guarantee the summary and the shown lines cannot disagree.

What I did not check

The 11-08/11-09 evidence behind #1615 (the nine entries that flipped when the SDK was reinstalled) — I have the tool and no installed 1bit-* tree on this box to sweep, so I verified the logic and the fixtures, not the numbers in the PR body. I also did not run the shell fixture: it needs patchelf, and the diff's assertions are readable enough that a reviewer's value here was in reading them rather than re-executing them.

@bong-water-water-bong
bong-water-water-bong merged commit 9b406f4 into main Nov 9, 2026
8 of 9 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the issue-1615-live-rpath branch November 9, 2026 08:31
bong-water-water-bong pushed a commit that referenced this pull request Nov 9, 2026
The fix for the build failure (98ada0b) appended a Copyright/SPDX pair to a file
that already carried the full Apache block, so the script ended up with two copies
eleven lines apart. tools/copyright.py --check passes either way (it reds on a
duplicate inside a narrower window), so this is not a gate failure - it is the
file disagreeing with every other file in the repo about how a header looks.

Same shape in two other files, one of them merged today via #1616
(tests/installed_rpath_test.sh, tools/npu-arena/make_task.sh): whoever is adding
notices is appending to files that already have them. Left those alone.

tools/copyright.py --check: rc=0 with no output. sh -n: clean.
bong-water-water-bong added a commit that referenced this pull request Nov 9, 2026
…ows (engine#823) (#1606)

* os: a boot capture for the AXB35-02 USB question, and what BIOS 1.10 shows (engine#823)

The owner reflashed to 1.10 (11/04/2026); this lane can measure the software side but not the plugin.

Measured on 1.10, and the reason the capture reports per-port connect state rather than controller power:
three of four xHCI controllers still autosuspend to D3cold, and the transition is software-controllable in
both directions - echo on -> D0, echo auto -> D3cold - so the issue's Windows-only/EC hypothesis is not
what is stopping the ports. What a woken controller does with a plugged device is only answerable by a
plug, which is the owner's, so the capture makes that answer durable.

tools/xhci_boot_capture.sh writes one bundle: firmware, per-controller power/control+power_state+
runtime_status, per-root-hub per-port connect state (lsusb -v; no debugfs assumption - this kernel has no
usb/xhci), udev rule presence, interrupt counts, lspci -vv, full and filtered dmesg, the repo's own
keepawake check verdict, and a one-screen VERDICT. It lists which tools the stick had, so an empty
section means 'no tool' and not 'no problem', and it hands the bundle back to the invoking user after
escalating, because a capture that needs sudo to read does not get sent.

Verified by running it on this host after the reflash: BIOS 1.10 / 11/04/2026 / BOSGAME LIMITED AXB35-02,
1 of 4 controllers in D0, bus 3 two ports with connect and bus 4 one, bundle written and owned by the
caller, rc=0.

* tools/xhci_boot_capture.sh: the licence notice the gate wants (Copyright bong-water-water-bong)

The build step 'Copyright notice on every file' failed on this PR: I wrote the holder as
bong-water-bong and the repo's gate wants the full Apache block with bong-water-water-bong. Fixed with
the repo's own tool (tools/copyright.py --fix), not by hand, so the text is exactly what the checker
accepts - tools/copyright.py --check is clean on the branch now.

* tools/xhci_boot_capture.sh: one notice, not two

The fix for the build failure (98ada0b) appended a Copyright/SPDX pair to a file
that already carried the full Apache block, so the script ended up with two copies
eleven lines apart. tools/copyright.py --check passes either way (it reds on a
duplicate inside a narrower window), so this is not a gate failure - it is the
file disagreeing with every other file in the repo about how a header looks.

Same shape in two other files, one of them merged today via #1616
(tests/installed_rpath_test.sh, tools/npu-arena/make_task.sh): whoever is adding
notices is appending to files that already have them. Left those alone.

tools/copyright.py --check: rc=0 with no output. sh -n: clean.

---------

Co-authored-by: pi-os3 <[email protected]>
Co-authored-by: bong-water-water-bong <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

installed 1bit-canonical / 1bit-pr-agent / 1bit-hrx-* load libomp.so from a mutable TheRock SDK path (no system copy exists)

1 participant