Skip to content

test: lake: cacheInsertPartial's preload replaces C library calls - #8

Merged
legion-implementer[bot] merged 3 commits into
fork/v4.36-lake-cache-insert-r21from
legion/LINUX-1736-lake-cache-insert
Nov 28, 2026
Merged

legion-implementer[bot] merged 3 commits into
fork/v4.36-lake-cache-insert-r21from
legion/LINUX-1736-lake-cache-insert

Conversation

@legion-implementer

@legion-implementer legion-implementer Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

cacheInsertPartial failed in the job "build / Linux release" on the tag
v4.36-machcsl-r20 for a defect of the test: its preload (NoHardLink.c)
replaced libuv's uv_fs_link and uv_fs_stat. A release build links libuv
statically into libleanshared.so, with -Bsymbolic, so the runtime's calls of
these functions bind inside that library and the preload never ran: on the tag
the hard link into the cache succeeded, and the test found no
"d2c4f49280adf1f1.art: not cached" line.

The preload now replaces the C library's link, which libuv's uv_fs_link
calls, and syscall for statx, which libuv's uv_fs_stat calls. A process
calls the C library through the dynamic linker, so the preload takes these
calls in a release as in any other build. The test's cases and expectations
are unchanged. fork/v4.36-lake-remote-fallback-flat carries the same
NoHardLink.c and gets the same change.

This is a change of the fork's release r21: it goes into the member branch fork/v4.36-lake-cache-insert-r21, which r21 merges in place of the member it copies. It merges as a squash after its review, when r21 is cut.

After its review, two more commits change the preload as in the service-mode member's copy: syscall is an x86-64/aarch64 entry that reads no argument and sends only statx to a typed function; typed hooks hold the C library's stat entry points too (libuv's fallback when statx fails); dlvsym only with glibc; no jump to address zero when the C library's syscall cannot be found.

Why this pull request's own build / Linux release is red: its job (https://github.com/sjawhar/lean4/actions/runs/46112017549/job/140877566857) stops at Upload Lake Cache, before any test: a pull request's run takes its workflow files from the member branch, which carries upstream's .github, and the fork has no Lake cache endpoint or key; the CI member (#6) fixes that step for the fork's runs. The members are tested together in the tree the cut takes: this pull request merges only at a head that a passing rehearsal of the release's integration includes, named here before the merge.

Dispatch: LINUX-1736

cacheInsertPartial failed in the job "build / Linux release" on the tag
v4.36-machcsl-r20 for a defect of the test: its preload (NoHardLink.c)
replaced libuv's `uv_fs_link` and `uv_fs_stat`. A release build links libuv
statically into libleanshared.so, with -Bsymbolic, so the runtime's calls of
these functions bind inside that library and the preload never ran: on the tag
the hard link into the cache succeeded, and the test found no
"d2c4f49280adf1f1.art: not cached" line.

The preload now replaces the C library's `link`, which libuv's `uv_fs_link`
calls, and `syscall` for `statx`, which libuv's `uv_fs_stat` calls. A process
calls the C library through the dynamic linker, so the preload takes these
calls in a release as in any other build. The test's cases and expectations
are unchanged. fork/v4.36-lake-remote-fallback-flat carries the same
NoHardLink.c and gets the same change.

Part of LINUX-1736.

Omp-Session: 01a21fea-50cc-71ef-b840-72b8c7ab62bb
Legion-Role: implementer
legion-implementer Bot added a commit that referenced this pull request Nov 28, 2026
…ntegration

The heads of the pull requests that make r21's CI member and its -r21 copies,
merged on the first integration commit: #6 (the CI member, on
the trunk), #7 (remoteExec, usageCutoffCrossTree and cacheInsertPartial in the
service-mode member), #8 (cacheInsertPartial in the cache-insert member), #9
(ccIdentity), #10 and #11 (usageCutoffCrossTree in the two pack members) and
#12 (the Windows declaration in the lazy-import-names member).

The merge needs no resolution: its tree is the first integration commit's
tree with each pull request's change, and where two of them make the same
change (usageCutoffCrossTree's writable lakefile, cacheInsertPartial's
preload) that change once.

Refs: LINUX-1736
Omp-Session: 01a21fea-50cc-71ef-b840-72b8c7ab62bb
Legion-Role: implementer
…and holds libc stat

Review of the previous commit found two defects in NoHardLink.c, the preload
of cacheInsertPartial:

- Its `syscall` read six `long` arguments with `va_arg` for every call,
  whatever the number: undefined behavior for a call with fewer arguments
  (libuv calls it with three for getrandom) or with other types (statx
  passes `int`s and pointers).
- It held only libuv's `syscall(SYS_statx, ...)`. Where statx fails with
  ENOSYS or EPERM (an old kernel, a seccomp filter), libuv calls the C
  library's `stat` instead, and the barrier of the writer-race case was
  never reached.

`syscall` is now a few instructions, for x86-64 and aarch64, that read no
argument and leave the argument registers and the stack as the caller set
them: for SYS_statx they jump to a C function whose parameters are the five
arguments of libuv's `uv__statx` with their types (int, const char *, int,
unsigned int, buffer), which holds the barrier or calls the C library's
`syscall` with exactly those; for any other number they jump to the C
library's `syscall`. On both processors a variadic call passes integer and
pointer arguments as a prototyped call does, so the jumps are defined by the
calling convention. The C library's `syscall` is looked up at the first
call, with the argument registers saved, since another library's
constructor can call `syscall` before this preload's would run.

The barrier also holds the C library's entry points that libuv's fallback
can reach, each with its own parameter types and each forwarding to the C
library's definition: `stat`, `stat64`, `fstatat`, `fstatat64` and `statx`
(glibc 2.28 and 2.33 on), and `__xstat`, `__xstat64`, `__fxstatat` and
`__fxstatat64`, which a library built against glibc before 2.33 calls (the
release builds against glibc 2.26), found by their glibc symbol version.
The comment on hard links now names only the path it covers: Lean's
`IO.FS.hardLink` calls libuv's synchronous `uv_fs_link`, which calls
`link`.

test.sh is unchanged: every case and assertion stays.

Checked with gcc 15 and glibc 2.43 on x86-64: the preload builds with
`-Wall -Wextra -Werror` (also at `-O2 -D_FORTIFY_SOURCE=2`). A driver
holds `syscall(SYS_statx, ...)`, `stat`, `stat64`, `fstatat`, `fstatat64`,
`statx` and the versioned `__xstat`, `__xstat64`, `__fxstatat` and
`__fxstatat64` for the barrier's path and passes other paths through, as
it does `syscall` for mmap (six arguments), getrandom and getpid, also from
a constructor that runs before the preload's; `link` fails for the chosen
prefix only. libuv 1.48.0, linked into a shared library with -Bsymbolic as
in a release, gives ENOENT for the barrier's path on the statx route and,
with statx refused by a seccomp filter, on its fallback to `stat`.

Part of LINUX-1736.

Omp-Session: 01a21fea-50cc-71ef-b840-72b8c7ab62bb
Legion-Role: implementer
legion-implementer Bot added a commit that referenced this pull request Nov 28, 2026
…tion

The new heads of three pull requests after their review, merged on the
previous integration commit: #6 (the CI member: `release_tag` is checked in
the one step that reads it and later steps read a Boolean), #7 and #8
(cacheInsertPartial's preload forwards `syscall` without reading its
arguments and holds the C library's stat entry points too).

The merge needs no resolution: its tree is the previous integration
commit's tree with the two changed files of these pull requests.

Refs: LINUX-1736
Omp-Session: 01a21fea-50cc-71ef-b840-72b8c7ab62bb
Legion-Role: implementer
…jump to null

Three points of the review of the previous commit, all in NoHardLink.c,
the preload of cacheInsertPartial; test.sh is unchanged.

- The versioned lookups of the pre-2.33 glibc names use `dlvsym`, which
  only glibc has, so the preload no longer compiled against musl. They
  now use it under `__GLIBC__` only, and `dlsym` otherwise (where those
  names do not exist, and the call fails with ENOSYS as for any missing
  definition).
- The hooks of the `stat` family and the function types they call through
  took `void *` buffers, so those types did not match the C library's. The
  file now declares `struct stat`, `struct stat64` and `struct statx`
  without defining them, and each hook and type takes its own one; the
  file still includes no <sys/stat.h>.
- If `dlsym(RTLD_NEXT, "syscall")` found nothing, the statx helper called
  address zero and the `syscall` instructions jumped to it. Both now go to
  `nhl_syscall_missing`, which sets errno to ENOSYS and returns -1.

Checked with gcc 15 and glibc 2.43 on x86-64: the preload builds with
`-Wall -Wextra -Werror` (also at `-O2 -D_FORTIFY_SOURCE=2`), and against
the headers of musl 1.2.5 too; the driver of the previous commit and the
libuv 1.48.0 test (statx route and, under a seccomp filter, the fallback to
`stat`) give the same results. A test build whose lookup of `syscall`
finds nothing makes `syscall` return -1 with ENOSYS, on the first call and
later ones, and in the statx helper, while the barrier still holds its path.

Part of LINUX-1736.

Omp-Session: 01a21fea-50cc-71ef-b840-72b8c7ab62bb
Legion-Role: implementer
legion-implementer Bot added a commit that referenced this pull request Nov 28, 2026
…ation

The new heads of #7 and #8 (cacheInsertPartial's preload: a musl build,
the stat structs' own pointer types, and no jump to address zero when the
C library's `syscall` cannot be found), merged on the previous integration
commit. The merge needs no resolution: its tree is the previous one with
the one changed file of these pull requests.

Refs: LINUX-1736
Omp-Session: 01a21fea-50cc-71ef-b840-72b8c7ab62bb
Legion-Role: implementer
@legion-implementer

Copy link
Copy Markdown
Author

Review pass by a reviewer of another model family (openai/gpt-6.2-sol), read-only, against the change's rules: a test changes only to fix its own defect, never to skip, exclude or loosen it.

  • Head 1bb3aece5345: changes needed. Two blocking findings on cacheInsertPartial's preload: its syscall read six long arguments for every call; and libuv's fallback to the C library's stat (when statx fails) bypassed the barrier.
    • Fixed in 389b851: syscall is an x86-64/aarch64 entry that reads no argument and sends SYS_statx to a typed function and every other call to the C library's syscall untouched; typed hooks on the C library's stat entry points.
  • Head 389b8516adaf: PASS per fix (2/2). Three non-blocking points: dlvsym breaks a musl build; the stat hooks used void * for their buffers; a missing syscall would branch to address zero.
    • Fixed in a522422: dlvsym only under __GLIBC__; the stat structs' own pointer types; ENOSYS when syscall cannot be found.
  • Head a522422ccdfb: PASS per fix (3/3), no new findings.

@legion-implementer

Copy link
Copy Markdown
Author

Release rehearsal: run 46160867934 passed on integration commit 9fddac80674ec8fa262b6720bb79ba745dd6ddf1, which includes this reviewed head a522422ccdfbdff7dcb0846c1753d7c576f9ddf3. The x86-64 and Arm64 test and source-tree checks and both Linux sanitizer jobs passed. The final release commit will have its own release CI run.

@legion-implementer
legion-implementer Bot marked this pull request as ready for review November 28, 2026 20:21
@legion-implementer
legion-implementer Bot merged commit 2e3e29c into fork/v4.36-lake-cache-insert-r21 Nov 28, 2026
24 of 26 checks passed
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.

0 participants