Skip to content

libc: preserve short program invocation names - #914

Closed
brandonpayton wants to merge 1 commit into
mainfrom
fix/program-invocation-short-name
Closed

libc: preserve short program invocation names#914
brandonpayton wants to merge 1 commit into
mainfrom
fix/program-invocation-short-name

Conversation

@brandonpayton

@brandonpayton brandonpayton commented Jul 13, 2026

Copy link
Copy Markdown
Member

Why

libc is the C standard library linked into Kandelo guest programs. It exposes one variable for the full executable name and another for only the final filename. Programs rely on that distinction to decide how they were invoked.

Restore the libc contract for program_invocation_short_name so programs receive the basename of argv[0], while program_invocation_name retains the full value.

Root cause

Kandelo's Wasm-specific __libc_start_main overlay copied argv[0] into both musl globals but omitted musl's basename scan. As a result, an invocation such as /opt/kandelo/bin/pkill exposed the same full path through both names. Procps uses the short name to distinguish pkill from pgrep, so real pkill incorrectly selected pgrep behavior.

What changed

  • Restore musl's upstream-equivalent slash scan in the Wasm overlay.
  • Extend the exec fixture to pass a path-valued argv[0] and assert both the full and basename forms.
  • Make the focused exec tests independent of the default rootfs fixture.

This does not change the host/kernel ABI. Statically linked user programs must be rebuilt to receive the corrected libc startup code.

Validation

  • ./scripts/dev-shell.sh bash scripts/build-musl.sh
  • ./scripts/dev-shell.sh scripts/build-programs.sh
  • ./scripts/dev-shell.sh bash -c 'cargo build --release -p kandelo -Z build-std=core,alloc'
  • rm -rf host/dist && ./scripts/dev-shell.sh bash -c 'cd host && npx vitest run test/exec.test.ts' - 2 passed
  • ./scripts/dev-shell.sh scripts/run-libc-tests.sh - 303 PASS, 20 expected XFAIL, 0 FAIL, 0 XPASS, 1 FLAKE-PASS
  • ./scripts/dev-shell.sh bash scripts/check-abi-version.sh - snapshot, C header, and TypeScript bindings in sync; no ABI change

Restore musl's basename derivation in the Wasm __libc_start_main overlay so program_invocation_short_name reflects argv[0] without its directory. Programs such as procps pkill use that standard libc identity to select behavior.\n\nExtend the exec regression fixture to cover both the full and short program invocation names.
@brandonpayton

Copy link
Copy Markdown
Member Author

Independent devil\u0027s-advocate review at exact head 0527559e7bc73c9153ee837c83e5c0d7ff7ebbe6 found no issues. The change restores upstream musl\u0027s basename scan exactly; procps-ng uses program_invocation_short_name to select PKILL mode. The regression exercises a real execve with path-valued argv[0] and validates both full and short exported names. Independent musl rebuild, complete fixture rebuild, focused exec tests (2/2), ABI consistency, and git diff --check passed. No ABI bump is required; statically linked programs must rebuild to receive the libc fix. No merge action taken.

@github-actions

Copy link
Copy Markdown
Contributor

Phase B-1 matrix build status — pr-914-staging

ABI v18. 68 built, 1 failed, 69 total.

Package Arch Status Sha
libcurl wasm32 built fb35c538
libcxx wasm32 built a4061a7c
libcxx wasm64 built 21405639
libpng wasm32 built 4e98a9f7
libxml2 wasm32 built dc49eb90
libxml2 wasm64 built 3df44f95
openssl wasm32 built d3a39163
openssl wasm64 built ae9791a7
sqlite wasm32 built 6441ae95
sqlite wasm64 built c461fe72
zlib wasm32 built 6b026711
zlib wasm64 built 71917474
bc wasm32 built b6095f08
bzip2 wasm32 built aa16fbf2
coreutils wasm32 built 4f5f89ab
curl wasm32 built 2f798aa5
dash wasm32 built 2568b6fd
diffutils wasm32 built 96d34530
dinit wasm32 built 3c8c98d7
fbdoom wasm32 built 65e769fa
file wasm32 built 630f0226
findutils wasm32 built 5032c58c
gawk wasm32 built 428a8ffe
git wasm32 built 0548a0c4
grep wasm32 built c1bb0ab0
gzip wasm32 built 8400ccbe
hello wasm32 built 6a7c1997
kandelo-sdk wasm32 built 177cad47
kernel wasm32 built a167648b
less wasm32 built b48d17fc
lsof wasm32 built 6c1473c0
m4 wasm32 built 9803a42c
make wasm32 built 785673ea
mariadb wasm32 built 267eb040
mariadb wasm64 built 780c0653
modeset wasm32 built 9bd96fc6
msmtpd wasm32 built f3a03988
nano wasm32 built 067080e1
ncurses wasm32 built 849a8bd1
netcat wasm32 built 11063a6f
nginx wasm32 built f2b47d32
php wasm32 built ab6df12b
posix-utils-lite wasm32 built 6792230f
ruby wasm32 built 78926340
sed wasm32 built 73026730
spidermonkey wasm32 built 8d3464fa
tar wasm32 built 53f5cfb1
tcl wasm32 built c6b3a3b9
unzip wasm32 built 7a7815a1
userspace wasm32 built 31c26384
vim wasm32 built 7465e9d7
wget wasm32 built 7c648b4f
xz wasm32 built 0c9bfdbb
zip wasm32 built 0f2a52da
zstd wasm32 built 02135b20
bash wasm32 built 2957e5dc
mariadb-test wasm32 built 62b4869f
mariadb-vfs wasm32 built 82e97653
mariadb-vfs wasm64 built e9d771d2
nethack wasm32 built 95437edf
node wasm32 built 631ebb31
spidermonkey-node wasm32 built e5d5d551
vim-browser-bundle wasm32 built f2165f03
nethack-browser-bundle wasm32 built 01c16aa7
rootfs wasm32 built 42a91d75
shell wasm32 failed
lamp wasm32 built ef4ad405
node-vfs wasm32 built f23a2f5a
wordpress wasm32 built 38cf4367

Auto-generated; replaced on each push. Raw data in the publish-status workflow artifact.

@brandonpayton

Copy link
Copy Markdown
Member Author

Absorbed by rebase-merged #967. Main is now 6efb411 with the sealed tree b133bfa018f7e2bc84c4845edf2f945b2f844954, and ABI 41 activation completed successfully in run 29550069085. The absorption audit confirmed this PR\x27s behavior and tests are present in that merged tree, so this source PR is closed and its branch is deleted.

@brandonpayton
brandonpayton deleted the fix/program-invocation-short-name branch July 17, 2026 02:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant