Skip to content

[16.0-stable] Make bpftrace-aotrt usable again - #7057

Merged
rene merged 5 commits into
lf-edge:16.0-stablefrom
christoph-zededa:16.0-fix-bpftrace
Nov 11, 2026
Merged

rene merged 5 commits into
lf-edge:16.0-stablefrom
christoph-zededa:16.0-fix-bpftrace

Conversation

@christoph-zededa

@christoph-zededa christoph-zededa commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Description

16.0-stable is the only branch on bpftrace 0.23.3. The alpine 3.22 series
(#5650, backported in #6707) carried the bump from 0.20.3 to 0.23.3, and the
follow-up #5803, which took master back to 0.20.3, was not backported because
16.0 was still on the old alpine at the time; 17.0, 14.5 and 13.4 run 0.20.3.
Since #6707 the AOT runtime in the debug container has not worked on this
branch: TestVGAPassthroughNoHostAccess fails with "Process exited with
status 127".

Four problems, each hidden behind the previous one:

  1. /usr/bin/bpftrace-aotrt does not start. 0.23.3 links libbfd, libopcodes
    and libpcap into the runtime, and pkg/bpftrace copies only the libraries
    0.20.3 needed next to it. Run by hand on the device: "Error relocating
    /usr/bin/bpftrace-aotrt: bfd_get_arch: symbol not found", exit 127.
  2. 0.23.3 changed how a program reaches the runtime, the format change that
    alpine 3.22: fix bpftrace #5803 names as the reason to go back: bpftrace --aot injects the payload
    into a copy of the shim as an ELF section, and the shim loads it from its
    own executable, takes no file argument and refuses to run under its own
    name. EVE uploads the raw payload (temp_btaot, kept by patch 0001) and runs
    bpftrace-aotrt -f json /tmp/bpf.aot, on this release as on all others.
  3. 0.23.3 compiles helper error checks into every program by default, but the
    helper error table is not part of the AOT payload (it is left out of
    RequiredResources::serialize). The first failed helper, here delete()
    of a key that was never inserted, is printed with a null helper name, which
    puts the runtime's JSON output stream into the failed state: nothing is
    printed after that line, and the test fails on the broken line.
  4. The VM image of eve-tools/bpftrace-compiler still pinned the eve-bpftrace
    built from 0.20.3 (c08d714d), whose output the 0.23.3 runtime rejects by
    the version hash in the AOT header.

The fix stays on 0.23.3 and leaves the branch's package set alone:

  • pkg/bpftrace ships the five missing libraries with the runtime and gains two
    patches: 0003 gives bpftrace-aotrt its file argument back, reads the file as
    the raw payload and parses the kernel BTF before running the program (the
    bpftrace binary does, and run() dereferences it for every program); 0004
    compiles ahead-of-time programs without helper error checks, as 0.20.3 did,
    which refused -k together with --aot. pkg/debug and pkg/installer move
    to the rebuilt package.
  • The compiler's root image pins that package, builds on the same eve-alpine
    and installs the LLVM 20, clang 20, binutils and libpcap libraries its
    bpftrace binary loads, which copy-out.sh collects through ldd.
  • Two commits cherry-picked from master: e71a6f4 from alpine 3.22: fix bpftrace #5803 (the compiler
    panicked on exit after a failed run, which turned the real error into a Go
    stack trace) and 26581c7 from evetest: fix recurring test and harness failures #7024 (qemu's vCPU threads write the
    passed-through device's config space on the guest's behalf; the test needs
    this on master as well).
  • A backport of Makefile: split bpftrace tests out of make test #6329 (2c33bb1, "Makefile: split bpftrace tests out of
    make test"). On this branch make test still ran the bpftrace-compiler
    tests inline, without building the checked-out pkg/bpftrace first, so the
    Go Tests job of this PR failed in TestCompileAmd64 with
    docker.io/lfedge/eve-bpftrace:7c4d9eff…: not found: the runner's cache
    is empty and a PR's package is not on Docker Hub. Master runs these tests
    from make test-bpftrace, which first builds pkg/bpftrace for amd64 and
    arm64 from the checked-out tree, with --pull so an architecture that is
    already published is fetched into the cache instead of rebuilt, and
    triggers them from their own workflow on changes to pkg/bpftrace,
    eve-tools/bpftrace-compiler and kernel-commits.mk. The earlier master half
    of that, 72501a6 prebuilding the package in the Go Tests workflow, came
    with alpine 3.22: fix bpftrace #5803 and so never reached 16.0 either. Adapted for this branch: the
    test target keeps make -C pkg/dnsmasq test where master has
    pkg/alpine/dnstest; the go-tests.yml and publish.yml hunks are empty here,
    16.0 never had the prebuild lines they remove; the CLAUDE.md hunk is
    dropped, the file does not exist on 16.0; the new bpftrace-tests.yml is
    master's current version, so it also carries the GIT_ASKPASS env block that
    build: authenticate github.com git fetches in CI #6682 added later and whose 16.0 backport [16.0-stable] build: authenticate github.com git fetches in CI #6972 could not add to a file
    that did not exist yet.

The alternative is to backport #5803 and return to 0.20.3. That needs llvm17
and clang17 in the 16.0 eve-alpine mirror and therefore rebuilds and
republishes every package of the branch. This PR is the minimal fix; its cost
is that 16.0 devices need a bpftrace-compiler built from this branch, as the
AOT payload is specific to the bpftrace version, while the revert would let
master's compiler serve 16.0 devices too.

PR dependencies

None. Cherry-picked with -x from master:
e71a6f4 (#5803),
26581c7 (#7024) and
2c33bb1 (#6329, with the adaptations listed
above).

How to test and validate this PR

  • make pkgs eve && EVETEST_PAUSE_ON_FAILURE=true make evetest NAME=TestVGAPassthroughNoHostAccess
    passes (583 s on 2026-11-06, amd64, KVM): the tracer compiles in the VM
    image, bpftrace-aotrt attaches its 11 probes on the device, the recorded
    accesses are parsed, and no host process touched the passed-through
    controller. Before this PR the same run fails at the end of phase 9 with
    "Process exited with status 127".
  • On a device: eve exec debug /usr/bin/bpftrace-aotrt --help prints the
    usage with a PROGRAM argument instead of "Error relocating
    /usr/bin/bpftrace-aotrt: bfd_get_arch: symbol not found", and
    bpftrace-compiler run-via-ssh <device>:22 examples/opensnoop.bt (built
    from this branch) prints opens.
  • make test-bpftrace from the repository root builds pkg/bpftrace for amd64
    and arm64 and runs the bpftrace-compiler tests against them; CI runs the
    same from the new BPFTrace Tests workflow, and Go Tests no longer runs
    these tests. Locally the arm64 package build needs binfmt, and
    TestCompileArm64 needs qemu-system-aarch64; without it the test is skipped,
    as on the CI runners.
  • To run the evetest before the packages are published: the compiler builds
    its VM image inside the evetest container, whose buildkit pulls
    lfedge/eve-bpftrace:<tag> from Docker Hub, so a locally built package has
    to be copied from ~/.linuxkit/cache into ~/.evetest/linuxkit-cache
    first (skopeo copy between the two OCI layouts). Not needed once the
    publish run has pushed the package.

Changelog notes

bpftrace scripts compiled with bpftrace-compiler run again on 16.0 devices:
the debug container's bpftrace-aotrt starts and accepts the compiled script.

PR Backports

  • 17.0-stable: No, the branch runs bpftrace 0.20.3 and has alpine 3.22: fix bpftrace #5803 and both
    cherry-picked commits. Its make test still runs the bpftrace-compiler
    tests inline, as on 14.5-stable and 13.4-stable, so the backport of Makefile: split bpftrace tests out of make test #6329
    would apply there as well; not part of this PR.
  • 16.0-stable: this PR.
  • 14.5-stable: No, bpftrace 0.20.3.
  • 13.4-stable: No, bpftrace 0.20.3.

Checklist

  • I've provided a proper description
  • I've added the proper documentation - none needed; the behaviour is
    described in the patch headers and commit messages, nothing user-facing
    changes.
  • I've tested my PR on amd64 device - the evetest run above, in a KVM VM.
  • I've tested my PR on arm64 device - no arm64 device at hand; the
    library names are the same on aarch64 (libbfd-2.44.so, libopcodes-2.44.so)
    and the patches are architecture-independent.
  • I've written the test verification instructions
  • I've set the proper labels to this PR - draft; no stable label, this
    is not a backport.

And the last but not least:

  • I've checked the boxes above, or I've provided a good reason why I didn't
    check them.

🤖 Generated with Claude Code

christoph-zededa and others added 2 commits November 6, 2026 14:36
16.0 is the only release on bpftrace 0.23.3: every other branch runs
0.20.3, and master went back to it in lf-edge#5803. Its debug container's
/usr/bin/bpftrace-aotrt does not start: TestVGAPassthroughNoHostAccess
fails with "Process exited with status 127", and run by hand on the
device the runtime reports libbfd-2.44.so and libopcodes-2.44.so as not
found. 0.23.3 links binutils' libraries and libpcap into the runtime,
and the Dockerfile copies only the libraries 0.20.3 needed next to it.

With the libraries in place the runtime still cannot serve EVE: between
0.20.3 and 0.23.3, bpftrace --aot stopped producing a payload file and
instead injects the payload into a copy of the bpftrace-aotrt shim as an
ELF section, which the shim then loads from its own executable, taking
no file argument and refusing to run under its own name.
bpftrace-compiler uploads the raw payload (temp_btaot, kept by patch
0001) and runs "bpftrace-aotrt -f json /tmp/bpf.aot", on this release as
on all others.

A third difference bites once the program runs: 0.23.3 compiles helper
error checks into the program by default (0.20.3 did not, and refused
-k together with --aot), but the helper error information is not part
of the AOT payload. The runtime formats the first failed helper, here
delete() of a key that was never inserted, with a null helper name,
which puts its JSON output stream into the failed state: nothing is
printed after that line, and the test fails on the broken line.

Ship the missing libraries with the runtime and add two patches: 0003
gives bpftrace-aotrt its file argument back, reads the file as the raw
payload and parses the kernel BTF before running the program, as the
bpftrace binary does and run() expects; 0004 compiles ahead-of-time
programs without helper error checks, as 0.20.3 did. The debug container
and the installer move to the rebuilt packages.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: Christoph Ostarek <christoph@zededa.com>
The tracer root image still pinned the eve-bpftrace built from 0.20.3
(c08d714) while the debug container on this branch runs 0.23.3. Both
sides check the bpftrace version through the hash in the AOT header, so
a script compiled in the VM is rejected by the device's runtime as a
build hash mismatch. Pin the package the debug container ships, build
the image on the same eve-alpine, and install the libraries its
bpftrace binary loads (LLVM and clang 20, binutils, libpcap), which
copy-out.sh collects through ldd. Compiled scripts are cached by the
content of root/, so results of the old image are not reused.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: Christoph Ostarek <christoph@zededa.com>
@christoph-zededa christoph-zededa added the bug Something isn't working label Nov 6, 2026
@codecov

codecov Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 33.55%. Comparing base (74e56a4) to head (3c70755).
⚠️ Report is 1 commits behind head on 16.0-stable.

Additional details and impacted files
@@               Coverage Diff               @@
##           16.0-stable    #7057      +/-   ##
===============================================
+ Coverage        31.67%   33.55%   +1.88%     
===============================================
  Files               10       15       +5     
  Lines             1026     2962    +1936     
===============================================
+ Hits               325      994     +669     
- Misses             701     1968    +1267     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

christoph-zededa and others added 3 commits November 9, 2026 12:05
check if stdout is already closed, if so do nothing

Signed-off-by: Christoph Ostarek <christoph@zededa.com>
(cherry picked from commit e71a6f4)
TestVGAPassthroughNoHostAccess failed in every nightly run with
"Host processes interfered with PCI devices ...: [app-restart]
pci_user_write_config_word comm=CPU 0/KVM pid=<qemu>". The tracer's
comm is the name of the calling thread, and QEMU names its vCPU threads
"CPU <n>/KVM". The guest's own config-space writes to the
passed-through device reach the kernel from those threads, but
isViolation allowed only threads named "qemu-system-*", so every write
of the guest was reported as host interference.

Allow QEMU's vCPU threads too. Only a qemu holding the device's VFIO
file can write its config space this way, so no access by another
process is let through.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Milan Lenco <milan@zededa.com>
(cherry picked from commit 26581c7)
The bpftrace-compiler tests boot QEMU for amd64 and arm64 and take
roughly 53 minutes, over half of the Go Tests workflow. Running them in
the middle of the test target also means a failure there skips every
remaining suite along with the coverage upload. They now live in
test-bpftrace, reached from test-all, with their own workflow triggered
only by changes to pkg/bpftrace, eve-tools/bpftrace-compiler or
kernel-commits.mk -- the three inputs they can regress from.

Building the arm64 eve-bpftrace package was also the only reason these
jobs touched a second architecture. linuxkit matches a FROM against its
local cache by name alone, so an entry populated for one architecture
hides the registry's multi-arch manifest from the other, and a package
published while the job runs can leave it building against an image it
cannot resolve. make test now stays on the host architecture throughout,
and test-bpftrace passes --pull so an already-published architecture is
fetched into the cache rather than skipped.

Signed-off-by: eriknordmark <erik@zededa.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 2c33bb1)
@christoph-zededa
christoph-zededa marked this pull request as ready for review November 9, 2026 12:40

@rene rene left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@eriknordmark eriknordmark left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@rene
rene merged commit 24e43ed into lf-edge:16.0-stable Nov 11, 2026
54 of 55 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants