From 7078434b2debd8dfe0bd9c25bb3c0a2329d11c81 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 20 Nov 2026 06:07:57 -0800 Subject: [PATCH 01/14] chore(quest): claim quest/m1/ffi-proofs/arm-sanitizers.md Quest-Claim: e048ff929bf4a260 From 0129f8c1b46f784c1826dbdd816de6e6274fad36 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 20 Nov 2026 06:08:38 -0800 Subject: [PATCH 02/14] DEBUG: arm sanitizers only --- .github/workflows/nightly.yml | 513 +--------------------------------- 1 file changed, 7 insertions(+), 506 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index cc3ffdc3a..5e3131aa0 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -17,269 +17,6 @@ concurrency: cancel-in-progress: true jobs: - bindings: - name: Binding packages - uses: ./.github/workflows/bindings-test.yml - - # The full check over every module, catching what a merge group's diff-scoped - # `just ci` let into main. - gate: - name: Gate - runs-on: ubuntu-24.04-arm - timeout-minutes: 60 - - steps: - - name: Checkout - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - - uses: ./.github/actions/nix - - - name: Gate - run: nix develop --command just gate - - ts: - name: TypeScript package - runs-on: ubuntu-24.04-arm - timeout-minutes: 60 - - steps: - - name: Checkout - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - - uses: ./.github/actions/nix - - # The package moq consumes as a flake input. - - name: Build - run: nix build .#ts - - # The fixtures against std checked in their own target directories, as outside Nix, - # whose snapshots hold the flake's sysroot to the same output. - - name: Fixtures without the sysroot - run: nix develop --command env RUST2_TS_SYSROOT= just ts test --test fixtures - - # WebCodecs' encoder both ways in headless Chromium, which only the bench shell - # carries, against the same build as the step before. - - name: Encoder in Chromium - run: nix develop .#bench --command env RUST2_TS_SYSROOT= just ts test --test fixtures -- --ignored --exact encoder - - bench: - name: Benchmark - runs-on: ubuntu-24.04-arm - timeout-minutes: 60 - - steps: - - name: Checkout - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - - uses: ./.github/actions/nix - - # Every route in Node, Bun, Chrome, and Firefox. The numbers go in the run's summary: no - # threshold fails the job. - - name: Bench - run: nix develop .#bench --command just ts bench - - - name: Summary - run: cat ts/target/bench/report.md >> "$GITHUB_STEP_SUMMARY" - - # moq's API on each target moq ships a binding to but the export's host, which the export - # merges into one binding: each staged where its C toolchain is, which moq's build scripts - # need even for a check. Linux's job takes Android's from the runner image's NDK. - ffi-api: - name: Stage moq's API (${{ matrix.name }}) - runs-on: ${{ matrix.os }} - timeout-minutes: 90 - strategy: - fail-fast: false - matrix: - include: - - name: Linux and Android - os: ubuntu-24.04 - targets: x86_64-unknown-linux-gnu aarch64-linux-android armv7-linux-androideabi x86_64-linux-android - - name: Apple - os: macos-latest - targets: aarch64-apple-darwin x86_64-apple-darwin aarch64-apple-ios aarch64-apple-ios-sim x86_64-apple-ios - - name: Windows - os: windows-latest - targets: x86_64-pc-windows-msvc - defaults: - run: - shell: bash - - steps: - # ffi/rust-toolchain.toml links to ts/'s. - - name: Symlinks - if: runner.os == 'Windows' - run: git config --global core.symlinks true - - - name: Checkout - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - - if: runner.os == 'Linux' - uses: ./.github/actions/nix - - # Elsewhere no Nix, as the C++ job: the runner's rustup installs rust-toolchain.toml's - # channel, and the targets it lacks. - - name: Install just - if: runner.os != 'Linux' - uses: taiki-e/install-action@3a3daafd3b7f23b8f65d9f5ba2db203fb59b79e2 # v2.90.2 - with: - tool: just - - - name: Targets - if: runner.os != 'Linux' - working-directory: ffi - run: | - read -ra targets <<< "$TARGETS" - rustup target add "${targets[@]}" - env: - TARGETS: ${{ matrix.targets }} - - - name: Stage - run: | - read -ra targets <<< "$TARGETS" - for target in "${targets[@]}"; do - if [ "$RUNNER_OS" = Linux ]; then - nix develop .#android --command just ffi moq-api "$target" - else - just ffi moq-api "$target" - fi - done - env: - TARGETS: ${{ matrix.targets }} - - - name: Upload - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 - with: - name: ffi-api-${{ runner.os }} - path: ffi/target/moq-api - if-no-files-found: error - - ffi: - name: Export moq-net to C - needs: ffi-api - runs-on: ubuntu-24.04-arm - timeout-minutes: 60 - - steps: - - name: Checkout - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - - uses: ./.github/actions/nix - - - name: Download - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 - with: - pattern: ffi-api-* - path: ffi/target/moq-api - merge-multiple: true - - # moq's pub API at the pinned moq revision on every target moq ships, merged into one - # binding, which fails on an item two targets define differently; built for the host, - # and driven from each language. - - name: Export - run: nix develop --command just ffi moq - - # Longer random protocol scripts through the C ABI and each binding, against the - # model of what each step returns; the gate runs fewer. - - name: Protocol - run: nix develop --command just ffi protocol - - # What exports, and every refusal, ranked. - - name: Census - run: nix develop --command just ffi census - - - name: Summarize - run: awk 'FNR == 1 { refused = 0 } /^## Refused items/ { refused = 1 } !refused' ffi/target/census/*.md >> "$GITHUB_STEP_SUMMARY" - - - name: Upload - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 - with: - name: ffi-census - path: ffi/target/census - - # The C++ header again with Clang, at each standard and with exceptions and RTTI on - # and off. C stays GCC's, so the export the steps above built stays fresh. - - name: Clang - run: nix develop .#clang --command bash -c 'export CC=gcc; just ffi test cpp && just ffi moq-cpp' - - # Every sampled type shape round-tripped in every language: the fixed set, then shapes - # drawn from the day's seed, which a failure names to reproduce it. The gate runs a - # subset. A job of its own, since it takes as long as the export's. - ffi-shapes: - name: Shapes in every language - runs-on: ubuntu-24.04-arm - timeout-minutes: 60 - - steps: - - name: Checkout - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - - uses: ./.github/actions/nix - - - name: Shapes - run: nix develop --command just ffi shapes - - # The pinned corpus of popular crates, each censused, exported through a facade, and - # bound in every language: a panic, an error, or a binding that does not build fails it. - # Their build scripts run here, on a runner of its own holding no secret. - ffi-corpus: - name: Export the crate corpus (${{ matrix.shard }}/4) - runs-on: ubuntu-24.04-arm - timeout-minutes: 120 - strategy: - fail-fast: false - matrix: - shard: [1, 2, 3, 4] - - steps: - - name: Checkout - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - - uses: ./.github/actions/nix - - - name: Corpus - run: nix develop --command just ffi corpus - env: - CORPUS_SHARD: ${{ matrix.shard }}/4 - - - name: Summarize - if: ${{ !cancelled() }} - run: cat ffi/target/tmp/corpus-${{ matrix.shard }}-of-4/report.md >> "$GITHUB_STEP_SUMMARY" - - # The api fixture's web test in headless Chromium, Firefox, and WebKit, which only the bench shell - # carries: a job of its own, so a browser's failure hides no other result. - ffi-web: - name: Web binding in browsers - runs-on: ubuntu-24.04-arm - timeout-minutes: 60 - - steps: - - name: Checkout - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - - uses: ./.github/actions/nix - - - name: Browsers - run: nix develop .#bench --command just ffi browsers - - # The api fixture's C and C++ scripts against glue built under AddressSanitizer and - # ThreadSanitizer, and its C ABI driven from Rust under Miri. ffi-sanitize: name: Export to C under sanitizers and Miri runs-on: ubuntu-24.04-arm @@ -293,251 +30,15 @@ jobs: - uses: ./.github/actions/nix + - name: Host + run: | + uname -a; cat /proc/sys/vm/mmap_rnd_bits /proc/sys/vm/mmap_rnd_compat_bits || true + getconf PAGESIZE; cat /proc/cpuinfo | grep -m1 -i 'model name\|cpu part' + - name: Sanitize - run: nix develop .#sanitize --command just ffi sanitize + run: nix develop .#sanitize --command bash -c 'cd ffi && for t in api_asan api_tsan api_swift_tsan; do cargo test --locked --test fixtures -- --ignored --exact $t 2>&1 | tail -40 || true; done' + # The C++ header with the compilers the job above lacks, through the same checks, the # Python on the platforms the job above lacks, and on macOS the Swift with Apple's # toolchain. - ffi-cpp: - name: Export moq-net to C++ (${{ matrix.name }}) - runs-on: ${{ matrix.os }} - timeout-minutes: 90 - strategy: - fail-fast: false - matrix: - include: - - name: MSVC - os: windows-latest - - name: Apple Clang - os: macos-latest - defaults: - run: - shell: bash - - steps: - # ffi/rust-toolchain.toml links to ts/'s. - - name: Symlinks - if: runner.os == 'Windows' - run: git config --global core.symlinks true - - - name: Checkout - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - # No Nix: its dev shell would replace the system compiler under test. The runner's - # rustup installs rust-toolchain.toml's channel. - - name: Install just - uses: taiki-e/install-action@3a3daafd3b7f23b8f65d9f5ba2db203fb59b79e2 # v2.90.2 - with: - tool: just - - # What a developer prompt sets for cl. VCINSTALLDIR stays unset, so rustc still finds - # its linker itself rather than Git's link.exe on PATH. - - name: MSVC - if: runner.os == 'Windows' - shell: pwsh - run: | - $vs = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath - & "$vs\Common7\Tools\Launch-VsDevShell.ps1" -Arch amd64 -HostArch amd64 -SkipAutomaticLocation - foreach ($name in 'INCLUDE', 'LIB', 'LIBPATH', 'PATH') { - "$name=$((Get-Item "env:$name").Value)" >> $env:GITHUB_ENV - } - - - name: Test - run: just ffi test cpp - - # The Python, on the runner's CPython, which Windows names `python`: its proactor - # loop reads wakes through a task rather than a reader callback. - - name: Python - run: just ffi test python - env: - PYTHON: ${{ runner.os == 'Windows' && 'python' || 'python3' }} - - - name: Export - run: just ffi moq-cpp - - # The Swift through the checks the merge gate runs with nixpkgs' Swift on Linux, then - # moq's session, reusing the builds above. - - name: Swift - if: runner.os == 'macOS' - run: just ffi test swift && just ffi moq-swift - - # The Kotlin on ART under CheckJNI, shrunk by R8 as an app shrinks it, and the library's - # abort messages and 16 KB alignment. x86_64, as moq's Android build: - # this image ships the Android SDK and NDK, and its KVM runs an x86_64 emulator at speed. - ffi-android: - name: Export to Kotlin on Android - runs-on: ubuntu-24.04 - timeout-minutes: 60 - - steps: - - name: Checkout - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - - uses: ./.github/actions/nix - - - name: Enable KVM - run: | - echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules - sudo udevadm control --reload-rules - sudo udevadm trigger --name-match=kvm - - # The oldest API level moq's Android library supports, then the one it compiles - # against. The second reuses the first's builds. - - name: API 24 - uses: reactivecircus/android-emulator-runner@a421e43855164a8197daf9d8d40fe71c6996bb0d # v2.38.0 - with: - api-level: 24 - arch: x86_64 - script: nix develop .#android --command just ffi android - - - name: API 35 - uses: reactivecircus/android-emulator-runner@a421e43855164a8197daf9d8d40fe71c6996bb0d # v2.38.0 - with: - api-level: 35 - arch: x86_64 - script: nix develop .#android --command just ffi android - - # A 32-bit ABI, as moq's armv7 build is, whose pointers and usize are half a long: - # x86, which this runner's KVM runs at speed. - - name: API 24, 32-bit - uses: reactivecircus/android-emulator-runner@a421e43855164a8197daf9d8d40fe71c6996bb0d # v2.38.0 - with: - api-level: 24 - arch: x86 - script: nix develop .#android --command just ffi android - - # An image whose kernel pages by 16 KB, as Google Play requires of 64-bit libraries from - # 2027-02-01: the library must load there, and its segments must align to that. - - name: API 35, 16 KB pages - uses: reactivecircus/android-emulator-runner@a421e43855164a8197daf9d8d40fe71c6996bb0d # v2.38.0 - with: - api-level: 35 - target: google_apis_ps16k - arch: x86_64 - script: | - test "$($ANDROID_HOME/platform-tools/adb shell getconf PAGE_SIZE | tr -d '\r')" = 16384 - nix develop .#android --command just ffi android - - ffi-bench: - name: Bench the bindings - runs-on: ubuntu-24.04-arm - timeout-minutes: 90 - - steps: - - name: Checkout - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - - uses: ./.github/actions/nix - - # The binding benchmark's tables go in the run's summary: no threshold fails the job. - - name: Bench - # Named, so a failing bench fails the pipe. - shell: bash - run: nix develop .#bench --command just ffi bench | tee -a "$GITHUB_STEP_SUMMARY" - - census: - name: Census moq-net and kio - runs-on: ubuntu-24.04-arm - timeout-minutes: 60 - - steps: - - name: Checkout - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - - uses: ./.github/actions/nix - - # Every construct translation refuses, at the pinned moq revision. - - name: Census - run: nix develop --command just ts census - - # The ranked tables: the spans would pass the summary's size limit. - - name: Summarize - run: awk 'FNR == 1 { spans = 0 } /^## Spans/ { spans = 1 } !spans' ts/target/census/moq-net.md ts/target/census/model.md ts/target/census/kio.md >> "$GITHUB_STEP_SUMMARY" - - - name: Upload - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 - with: - name: census - path: ts/target/census - - # Every driver on the newest nightly rust-overlay names, so the next bump's breaks are - # known before it starts. It fails no merge and opens no issue: the report waits on - # every job but this one. Each module runs after another's failure. - canary: - name: Newest nightly - runs-on: ubuntu-24.04-arm - timeout-minutes: 90 - continue-on-error: true - - steps: - - name: Checkout - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - persist-credentials: false - - - uses: ./.github/actions/nix - - - name: Toolchain - id: toolchain - run: | - channel=$(sh/canary.sh) - echo "Canary on \`$channel\`" >> "$GITHUB_STEP_SUMMARY" - - - name: Driver - if: ${{ !cancelled() && steps.toolchain.outcome == 'success' }} - run: nix develop --command bash -c 'just driver check && just driver test' - - - name: Export - if: ${{ !cancelled() && steps.toolchain.outcome == 'success' }} - run: nix develop --command bash -c 'just ffi check && just ffi test' - - - name: Go - if: ${{ !cancelled() && steps.toolchain.outcome == 'success' }} - run: nix develop --command bash -c 'just go check && just go test' - - - name: TypeScript - if: ${{ !cancelled() && steps.toolchain.outcome == 'success' }} - run: nix develop --command bash -c 'just ts check && just ts moq && just ts test' - - # A scheduled run's failure opens one issue, or comments on the one still open, and a - # pass closes it, so a suite only this workflow runs cannot fail unseen. Only the - # schedule, which runs main, gets the write token: a dispatch can run any branch. - report: - name: Report - needs: [bindings, gate, ts, bench, ffi-api, ffi, ffi-shapes, ffi-corpus, ffi-web, ffi-sanitize, ffi-cpp, ffi-android, ffi-bench, census] - if: ${{ !cancelled() && github.event_name == 'schedule' }} - runs-on: ubuntu-24.04 - timeout-minutes: 5 - permissions: - issues: write - - steps: - - name: Issue - env: - GH_TOKEN: ${{ github.token }} - GH_REPO: ${{ github.repository }} - FAILED: ${{ contains(needs.*.result, 'failure') }} - RUN: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - SHA: ${{ github.sha }} - run: | - title="The nightly fails" - issue=$(gh issue list --state open --search "\"$title\" in:title" --json number,title --jq ".[] | select(.title == \"$title\") | .number" | head -n 1) - if [ "$FAILED" = true ]; then - body="[This run]($RUN) failed at $SHA." - if [ -n "$issue" ]; then - gh issue comment "$issue" --body "$body" - else - gh issue create --title "$title" --body "$body" - fi - elif [ -n "$issue" ]; then - gh issue close "$issue" --comment "[This run]($RUN) passed at $SHA." - fi From 1c9c86d47cad8690e32438c507f2ebf56d677ec0 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 20 Nov 2026 06:14:42 -0800 Subject: [PATCH 03/14] DEBUG: toolchain path --- .github/workflows/nightly.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 5e3131aa0..75be175b5 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -36,7 +36,7 @@ jobs: getconf PAGESIZE; cat /proc/cpuinfo | grep -m1 -i 'model name\|cpu part' - name: Sanitize - run: nix develop .#sanitize --command bash -c 'cd ffi && for t in api_asan api_tsan api_swift_tsan; do cargo test --locked --test fixtures -- --ignored --exact $t 2>&1 | tail -40 || true; done' + run: nix develop .#sanitize --command bash -c 'cd ffi && export PATH=$RUST2_TS_TOOLCHAIN/bin:$PATH && for t in api_asan api_tsan api_swift_tsan; do cargo test --locked --test fixtures -- --ignored --exact $t 2>&1 | tail -40 || true; done' # The C++ header with the compilers the job above lacks, through the same checks, the From 9f5014e299899a49985d231b71cfa64ce24e00be Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 20 Nov 2026 06:24:46 -0800 Subject: [PATCH 04/14] DEBUG: lower rnd bits --- .github/workflows/nightly.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 75be175b5..24995dded 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -33,7 +33,7 @@ jobs: - name: Host run: | uname -a; cat /proc/sys/vm/mmap_rnd_bits /proc/sys/vm/mmap_rnd_compat_bits || true - getconf PAGESIZE; cat /proc/cpuinfo | grep -m1 -i 'model name\|cpu part' + sudo sysctl vm.mmap_rnd_bits vm.mmap_rnd_compat_bits; sudo sysctl -w vm.mmap_rnd_bits=28; getconf PAGESIZE; getconf VA_BITS; cat /proc/cpuinfo | grep -m1 -i 'model name\|cpu part' - name: Sanitize run: nix develop .#sanitize --command bash -c 'cd ffi && export PATH=$RUST2_TS_TOOLCHAIN/bin:$PATH && for t in api_asan api_tsan api_swift_tsan; do cargo test --locked --test fixtures -- --ignored --exact $t 2>&1 | tail -40 || true; done' From 10276b7d63e1b163e4c39520dc75f0d36767f426 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 20 Nov 2026 06:25:23 -0800 Subject: [PATCH 05/14] DEBUG: lldb --- .github/workflows/nightly.yml | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 24995dded..2f364d416 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -33,12 +33,32 @@ jobs: - name: Host run: | uname -a; cat /proc/sys/vm/mmap_rnd_bits /proc/sys/vm/mmap_rnd_compat_bits || true - sudo sysctl vm.mmap_rnd_bits vm.mmap_rnd_compat_bits; sudo sysctl -w vm.mmap_rnd_bits=28; getconf PAGESIZE; getconf VA_BITS; cat /proc/cpuinfo | grep -m1 -i 'model name\|cpu part' + sudo sysctl vm.mmap_rnd_bits vm.mmap_rnd_compat_bits; getconf PAGESIZE; cat /proc/cpuinfo | grep -m1 -i 'model name\|cpu part' - name: Sanitize run: nix develop .#sanitize --command bash -c 'cd ffi && export PATH=$RUST2_TS_TOOLCHAIN/bin:$PATH && for t in api_asan api_tsan api_swift_tsan; do cargo test --locked --test fixtures -- --ignored --exact $t 2>&1 | tail -40 || true; done' + - name: Debug + if: always() + run: | + nix develop .#sanitize --command bash -c ' + cd ffi/target/tmp/api + ls address thread || true + for d in address thread; do + echo "== $d" + ASAN_OPTIONS=verbosity=2:abort_on_error=1 TSAN_OPTIONS=verbosity=2 $d/api-c 2>&1 | tail -30 + echo "exit $?" + lldb -b -o "settings set target.process.stop-on-sharedlibrary-events false" -o run -o bt -o "register read" -o "image list" -- $d/api-c 2>&1 | tail -60 + done + cat > /tmp/hello.c < + int main(){puts("hi");return 0;} + EOF2 + for s in address thread; do clang -fsanitize=$s /tmp/hello.c -o /tmp/hello-$s && /tmp/hello-$s; echo "hello $s exit $?"; done + clang --version + ' + # The C++ header with the compilers the job above lacks, through the same checks, the # Python on the platforms the job above lacks, and on macOS the Swift with Apple's # toolchain. From b693c0b22c29ee8265207842273fe621b0036d27 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 20 Nov 2026 06:35:56 -0800 Subject: [PATCH 06/14] DEBUG: more --- .github/workflows/nightly.yml | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 2f364d416..490291bd8 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -43,20 +43,26 @@ jobs: if: always() run: | nix develop .#sanitize --command bash -c ' + export PATH=$RUST2_TS_TOOLCHAIN/bin:$PATH + rustc -vV cd ffi/target/tmp/api - ls address thread || true for d in address thread; do echo "== $d" - ASAN_OPTIONS=verbosity=2:abort_on_error=1 TSAN_OPTIONS=verbosity=2 $d/api-c 2>&1 | tail -30 - echo "exit $?" - lldb -b -o "settings set target.process.stop-on-sharedlibrary-events false" -o run -o bt -o "register read" -o "image list" -- $d/api-c 2>&1 | tail -60 + ASAN_OPTIONS=verbosity=1 TSAN_OPTIONS=verbosity=1 $d/api-c 2>&1 | head -40 + echo "exit ${PIPESTATUS[0]}" + lldb -b -o run -o "thread backtrace" -- $d/api-c 2>&1 | grep -E "^ *frame" | head -20 done - cat > /tmp/hello.c < - int main(){puts("hi");return 0;} - EOF2 - for s in address thread; do clang -fsanitize=$s /tmp/hello.c -o /tmp/hello-$s && /tmp/hello-$s; echo "hello $s exit $?"; done - clang --version + mkdir -p /tmp/h; cd /tmp/h + printf "fn main(){println!(\"hi\");}" > h.rs + printf "int main(){return 0;}" > h.c + clang -fsanitize=address -c h.c -o h.o + clang -fsanitize=address h.c -o hc && ASAN_OPTIONS=verbosity=1 ./hc 2>&1 | head -20 + for s in address thread; do + rustc -Zsanitizer=$s h.rs -o hr-$s --target aarch64-unknown-linux-gnu && ./hr-$s; echo "rust hello $s exit $?" + rustc -Zsanitizer=$s h.rs --emit=llvm-ir -o hr-$s.ll --target aarch64-unknown-linux-gnu; grep -m5 -E "shadow|inttoptr|add i64" hr-$s.ll + clang -fsanitize=$s -### h.c 2>&1 | tr " " "\n" | grep -i -E "asan|tsan|rtlib|clang_rt|shared" | head + done + ls /nix/store | grep -E "compiler-rt|clang-" | head -20 ' # The C++ header with the compilers the job above lacks, through the same checks, the From 0a2aaa1c06c5b7e733ae856c99a7f342e6a8debe Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 20 Nov 2026 06:46:37 -0800 Subject: [PATCH 07/14] DEBUG: init order --- .github/workflows/nightly.yml | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 490291bd8..2e4391cc2 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -43,26 +43,14 @@ jobs: if: always() run: | nix develop .#sanitize --command bash -c ' - export PATH=$RUST2_TS_TOOLCHAIN/bin:$PATH - rustc -vV - cd ffi/target/tmp/api - for d in address thread; do - echo "== $d" - ASAN_OPTIONS=verbosity=1 TSAN_OPTIONS=verbosity=1 $d/api-c 2>&1 | head -40 - echo "exit ${PIPESTATUS[0]}" - lldb -b -o run -o "thread backtrace" -- $d/api-c 2>&1 | grep -E "^ *frame" | head -20 - done - mkdir -p /tmp/h; cd /tmp/h - printf "fn main(){println!(\"hi\");}" > h.rs - printf "int main(){return 0;}" > h.c - clang -fsanitize=address -c h.c -o h.o - clang -fsanitize=address h.c -o hc && ASAN_OPTIONS=verbosity=1 ./hc 2>&1 | head -20 - for s in address thread; do - rustc -Zsanitizer=$s h.rs -o hr-$s --target aarch64-unknown-linux-gnu && ./hr-$s; echo "rust hello $s exit $?" - rustc -Zsanitizer=$s h.rs --emit=llvm-ir -o hr-$s.ll --target aarch64-unknown-linux-gnu; grep -m5 -E "shadow|inttoptr|add i64" hr-$s.ll - clang -fsanitize=$s -### h.c 2>&1 | tr " " "\n" | grep -i -E "asan|tsan|rtlib|clang_rt|shared" | head - done - ls /nix/store | grep -E "compiler-rt|clang-" | head -20 + cd ffi/target/tmp/api/address + readelf -SW api-c | grep -E "init_array|preinit|fini_array|\.tdata|\.tbss|\.got" + readelf -rW api-c | grep -c . + readelf -x .init_array api-c; readelf -x .preinit_array api-c + nm -n api-c | grep -E " (asan.module_ctor|__asan_init|_GLOBAL__sub_I|__asan_version)|module_ctor" | head -20 + lldb -b -o "b __asan_init" -o "b __asan_version_mismatch_check_v8" -o run -o "bt" -o "register read lr pc sp" -o c -o bt -- api-c 2>&1 | grep -v "^ *$" | head -60 + echo ==== lldb2 + lldb -b -o run -o "register read" -o "x/6i \$pc-8" -o "image lookup -a \$lr" -o "memory read --size 8 --count 12 \$sp" -- api-c 2>&1 | tail -50 ' # The C++ header with the compilers the job above lacks, through the same checks, the From 521b8447961dff84afb2ba02aaaff1f908bebc15 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 20 Nov 2026 06:57:41 -0800 Subject: [PATCH 08/14] DEBUG: clang 23 for sanitize --- .github/workflows/nightly.yml | 14 -------------- flake.nix | 5 +++-- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 2e4391cc2..db8e9f17a 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -39,20 +39,6 @@ jobs: run: nix develop .#sanitize --command bash -c 'cd ffi && export PATH=$RUST2_TS_TOOLCHAIN/bin:$PATH && for t in api_asan api_tsan api_swift_tsan; do cargo test --locked --test fixtures -- --ignored --exact $t 2>&1 | tail -40 || true; done' - - name: Debug - if: always() - run: | - nix develop .#sanitize --command bash -c ' - cd ffi/target/tmp/api/address - readelf -SW api-c | grep -E "init_array|preinit|fini_array|\.tdata|\.tbss|\.got" - readelf -rW api-c | grep -c . - readelf -x .init_array api-c; readelf -x .preinit_array api-c - nm -n api-c | grep -E " (asan.module_ctor|__asan_init|_GLOBAL__sub_I|__asan_version)|module_ctor" | head -20 - lldb -b -o "b __asan_init" -o "b __asan_version_mismatch_check_v8" -o run -o "bt" -o "register read lr pc sp" -o c -o bt -- api-c 2>&1 | grep -v "^ *$" | head -60 - echo ==== lldb2 - lldb -b -o run -o "register read" -o "x/6i \$pc-8" -o "image lookup -a \$lr" -o "memory read --size 8 --count 12 \$sp" -- api-c 2>&1 | tail -50 - ' - # The C++ header with the compilers the job above lacks, through the same checks, the # Python on the platforms the job above lacks, and on macOS the Swift with Apple's # toolchain. diff --git a/flake.nix b/flake.nix index 417d2b8ac..981249beb 100644 --- a/flake.nix +++ b/flake.nix @@ -344,9 +344,10 @@ # `just ffi sanitize` builds the glue with the nightly's sanitizers, linked by clang, # runs it under the nightly's Miri and Valgrind, and runs the Python on a debug build of # the newest CPython, which nothing caches. llvm-symbolizer names a report's frames. - devShells.sanitize = self.devShells.${system}.clang.overrideAttrs (old: { + devShells.sanitize = self.devShells.${system}.default.overrideAttrs (old: { nativeBuildInputs = old.nativeBuildInputs ++ [ - pkgs.llvm + pkgs.llvmPackages_23.clang + pkgs.llvmPackages_23.llvm pkgs.valgrind ]; RUST2_PYTHON_DEBUG = "${pkgs.python315.override { enableDebug = true; }}/bin/python3"; From 2495e1d740775eb6b9f7e8b72767b8657d480632 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 20 Nov 2026 07:08:08 -0800 Subject: [PATCH 09/14] DEBUG: ir --- .github/workflows/nightly.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index db8e9f17a..df9a6f4b4 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -39,6 +39,21 @@ jobs: run: nix develop .#sanitize --command bash -c 'cd ffi && export PATH=$RUST2_TS_TOOLCHAIN/bin:$PATH && for t in api_asan api_tsan api_swift_tsan; do cargo test --locked --test fixtures -- --ignored --exact $t 2>&1 | tail -40 || true; done' + - name: Debug + if: always() + run: | + nix develop .#sanitize --command bash -c ' + clang --version | head -1 + mkdir -p /tmp/h; cd /tmp/h + printf "int g; int main(int c,char**v){return g+v[0][0];}" > h.c + clang -O0 -fsanitize=address -S -emit-llvm h.c -o - | grep -E "add|shl|lshr|dynamic|shadow" | head + ASAN_OPTIONS=verbosity=1 clang -fsanitize=address h.c -o hc && ASAN_OPTIONS=verbosity=1 ./hc 2>&1 | grep -vE "intercept|root region" | head -30 + cd /home/runner/work/rust2/rust2/ffi/target/tmp/api/address + ASAN_OPTIONS=verbosity=1 ./api-c 2>&1 | head; + cat /proc/self/maps | head -30 + ldd api-c | head; file api-c + ' + # The C++ header with the compilers the job above lacks, through the same checks, the # Python on the platforms the job above lacks, and on macOS the Swift with Apple's # toolchain. From 9cd86f5838e92b62127431c19138ac81ecafa490 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 20 Nov 2026 07:18:56 -0800 Subject: [PATCH 10/14] DEBUG: lldb stdin --- .github/workflows/nightly.yml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index df9a6f4b4..232fd55cf 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -43,15 +43,11 @@ jobs: if: always() run: | nix develop .#sanitize --command bash -c ' - clang --version | head -1 - mkdir -p /tmp/h; cd /tmp/h - printf "int g; int main(int c,char**v){return g+v[0][0];}" > h.c - clang -O0 -fsanitize=address -S -emit-llvm h.c -o - | grep -E "add|shl|lshr|dynamic|shadow" | head - ASAN_OPTIONS=verbosity=1 clang -fsanitize=address h.c -o hc && ASAN_OPTIONS=verbosity=1 ./hc 2>&1 | grep -vE "intercept|root region" | head -30 + which -a clang | head; clang --version | head -1 cd /home/runner/work/rust2/rust2/ffi/target/tmp/api/address - ASAN_OPTIONS=verbosity=1 ./api-c 2>&1 | head; - cat /proc/self/maps | head -30 - ldd api-c | head; file api-c + printf "b __asan_init\nrun\nfinish\nbt\nregister read x30\nimage lookup -a \$x30\nc\nbt\nregister read x30 x0 x1 x2 x8\nimage lookup -a \$x30\nx/8i \$pc-16\nthread backtrace all\nquit\n" | lldb api-c 2>&1 | tail -80 + ASAN_OPTIONS=verbosity=1 ./api-c 2>&1 | head -5 + ldd api-c | head -3 ' # The C++ header with the compilers the job above lacks, through the same checks, the From 0a58f08fcf53a26af557a7dfbe364c02e1805646 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 20 Nov 2026 07:29:20 -0800 Subject: [PATCH 11/14] DEBUG: gdb --- .github/workflows/nightly.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 232fd55cf..08cfea651 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -43,11 +43,9 @@ jobs: if: always() run: | nix develop .#sanitize --command bash -c ' - which -a clang | head; clang --version | head -1 cd /home/runner/work/rust2/rust2/ffi/target/tmp/api/address - printf "b __asan_init\nrun\nfinish\nbt\nregister read x30\nimage lookup -a \$x30\nc\nbt\nregister read x30 x0 x1 x2 x8\nimage lookup -a \$x30\nx/8i \$pc-16\nthread backtrace all\nquit\n" | lldb api-c 2>&1 | tail -80 - ASAN_OPTIONS=verbosity=1 ./api-c 2>&1 | head -5 - ldd api-c | head -3 + nm -C api-c | grep -i -E "__aarch64_|have_lse|outline" | head -20 + nix shell nixpkgs#gdb --command gdb -batch -ex "run" -ex "bt 15" -ex "info registers x30 pc" -ex "x/6i \$pc-12" ./api-c 2>&1 | tail -40 ' # The C++ header with the compilers the job above lacks, through the same checks, the From 74039ea1d7052461c4749b4c5ea4a05ee5018f23 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 20 Nov 2026 07:41:33 -0800 Subject: [PATCH 12/14] DEBUG: fix, full sanitize --- .github/workflows/nightly.yml | 11 +---------- ffi/tests/fixtures.rs | 11 ++++++++++- flake.nix | 5 ++--- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 08cfea651..2a8288d16 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -36,18 +36,9 @@ jobs: sudo sysctl vm.mmap_rnd_bits vm.mmap_rnd_compat_bits; getconf PAGESIZE; cat /proc/cpuinfo | grep -m1 -i 'model name\|cpu part' - name: Sanitize - run: nix develop .#sanitize --command bash -c 'cd ffi && export PATH=$RUST2_TS_TOOLCHAIN/bin:$PATH && for t in api_asan api_tsan api_swift_tsan; do cargo test --locked --test fixtures -- --ignored --exact $t 2>&1 | tail -40 || true; done' + run: nix develop .#sanitize --command just ffi sanitize - - name: Debug - if: always() - run: | - nix develop .#sanitize --command bash -c ' - cd /home/runner/work/rust2/rust2/ffi/target/tmp/api/address - nm -C api-c | grep -i -E "__aarch64_|have_lse|outline" | head -20 - nix shell nixpkgs#gdb --command gdb -batch -ex "run" -ex "bt 15" -ex "info registers x30 pc" -ex "x/6i \$pc-12" ./api-c 2>&1 | tail -40 - ' - # The C++ header with the compilers the job above lacks, through the same checks, the # Python on the platforms the job above lacks, and on macOS the Swift with Apple's # toolchain. diff --git a/ffi/tests/fixtures.rs b/ffi/tests/fixtures.rs index 0ab75ba8d..b257e29f3 100644 --- a/ffi/tests/fixtures.rs +++ b/ffi/tests/fixtures.rs @@ -528,6 +528,15 @@ fn api_valgrind() { fn sanitized_glue(sanitizer: &str) -> (PathBuf, Vec) { let api = api(); let dir = scratch().join("api").join(sanitizer); + // On aarch64, the runtime's atomics call `__aarch64_*` helpers, which the instrumented + // compiler_builtins would define and answer by reading a flag through a shadow check, before + // the runtime has mapped its shadow: every run would crash in `__asan_init` or `__tsan_init`. + // Without them the link takes the toolchain's own, which are not instrumented. + let outline = if cfg!(target_arch = "aarch64") { + " -Ctarget-feature=-outline-atomics" + } else { + "" + }; let built = run(cargo() .args(["build", "--quiet", "--locked", "-Zbuild-std", "--target", host()]) .arg("--manifest-path") @@ -536,7 +545,7 @@ fn sanitized_glue(sanitizer: &str) -> (PathBuf, Vec) { .arg(dir.join("glue")) .env( "RUSTFLAGS", - format!("-D warnings -Zsanitizer={sanitizer} --print=native-static-libs"), + format!("-D warnings -Zsanitizer={sanitizer} --print=native-static-libs{outline}"), )); let native: Vec = String::from_utf8_lossy(&built.stderr) .lines() diff --git a/flake.nix b/flake.nix index 981249beb..417d2b8ac 100644 --- a/flake.nix +++ b/flake.nix @@ -344,10 +344,9 @@ # `just ffi sanitize` builds the glue with the nightly's sanitizers, linked by clang, # runs it under the nightly's Miri and Valgrind, and runs the Python on a debug build of # the newest CPython, which nothing caches. llvm-symbolizer names a report's frames. - devShells.sanitize = self.devShells.${system}.default.overrideAttrs (old: { + devShells.sanitize = self.devShells.${system}.clang.overrideAttrs (old: { nativeBuildInputs = old.nativeBuildInputs ++ [ - pkgs.llvmPackages_23.clang - pkgs.llvmPackages_23.llvm + pkgs.llvm pkgs.valgrind ]; RUST2_PYTHON_DEBUG = "${pkgs.python315.override { enableDebug = true; }}/bin/python3"; From 5c316dd1c47969fc39f7ef3ce4f8e93805fd41b2 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 20 Nov 2026 07:58:18 -0800 Subject: [PATCH 13/14] fix(ffi): sanitizers run on aarch64 without the instrumented outline atomics --- .github/workflows/nightly.yml | 511 +++++++++++++++++++++++++- quest/m1/ffi-proofs/arm-sanitizers.md | 28 -- 2 files changed, 505 insertions(+), 34 deletions(-) delete mode 100644 quest/m1/ffi-proofs/arm-sanitizers.md diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 2a8288d16..cc3ffdc3a 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -17,8 +17,57 @@ concurrency: cancel-in-progress: true jobs: - ffi-sanitize: - name: Export to C under sanitizers and Miri + bindings: + name: Binding packages + uses: ./.github/workflows/bindings-test.yml + + # The full check over every module, catching what a merge group's diff-scoped + # `just ci` let into main. + gate: + name: Gate + runs-on: ubuntu-24.04-arm + timeout-minutes: 60 + + steps: + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - uses: ./.github/actions/nix + + - name: Gate + run: nix develop --command just gate + + ts: + name: TypeScript package + runs-on: ubuntu-24.04-arm + timeout-minutes: 60 + + steps: + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - uses: ./.github/actions/nix + + # The package moq consumes as a flake input. + - name: Build + run: nix build .#ts + + # The fixtures against std checked in their own target directories, as outside Nix, + # whose snapshots hold the flake's sysroot to the same output. + - name: Fixtures without the sysroot + run: nix develop --command env RUST2_TS_SYSROOT= just ts test --test fixtures + + # WebCodecs' encoder both ways in headless Chromium, which only the bench shell + # carries, against the same build as the step before. + - name: Encoder in Chromium + run: nix develop .#bench --command env RUST2_TS_SYSROOT= just ts test --test fixtures -- --ignored --exact encoder + + bench: + name: Benchmark runs-on: ubuntu-24.04-arm timeout-minutes: 60 @@ -30,15 +79,465 @@ jobs: - uses: ./.github/actions/nix - - name: Host + # Every route in Node, Bun, Chrome, and Firefox. The numbers go in the run's summary: no + # threshold fails the job. + - name: Bench + run: nix develop .#bench --command just ts bench + + - name: Summary + run: cat ts/target/bench/report.md >> "$GITHUB_STEP_SUMMARY" + + # moq's API on each target moq ships a binding to but the export's host, which the export + # merges into one binding: each staged where its C toolchain is, which moq's build scripts + # need even for a check. Linux's job takes Android's from the runner image's NDK. + ffi-api: + name: Stage moq's API (${{ matrix.name }}) + runs-on: ${{ matrix.os }} + timeout-minutes: 90 + strategy: + fail-fast: false + matrix: + include: + - name: Linux and Android + os: ubuntu-24.04 + targets: x86_64-unknown-linux-gnu aarch64-linux-android armv7-linux-androideabi x86_64-linux-android + - name: Apple + os: macos-latest + targets: aarch64-apple-darwin x86_64-apple-darwin aarch64-apple-ios aarch64-apple-ios-sim x86_64-apple-ios + - name: Windows + os: windows-latest + targets: x86_64-pc-windows-msvc + defaults: + run: + shell: bash + + steps: + # ffi/rust-toolchain.toml links to ts/'s. + - name: Symlinks + if: runner.os == 'Windows' + run: git config --global core.symlinks true + + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - if: runner.os == 'Linux' + uses: ./.github/actions/nix + + # Elsewhere no Nix, as the C++ job: the runner's rustup installs rust-toolchain.toml's + # channel, and the targets it lacks. + - name: Install just + if: runner.os != 'Linux' + uses: taiki-e/install-action@3a3daafd3b7f23b8f65d9f5ba2db203fb59b79e2 # v2.90.2 + with: + tool: just + + - name: Targets + if: runner.os != 'Linux' + working-directory: ffi + run: | + read -ra targets <<< "$TARGETS" + rustup target add "${targets[@]}" + env: + TARGETS: ${{ matrix.targets }} + + - name: Stage run: | - uname -a; cat /proc/sys/vm/mmap_rnd_bits /proc/sys/vm/mmap_rnd_compat_bits || true - sudo sysctl vm.mmap_rnd_bits vm.mmap_rnd_compat_bits; getconf PAGESIZE; cat /proc/cpuinfo | grep -m1 -i 'model name\|cpu part' + read -ra targets <<< "$TARGETS" + for target in "${targets[@]}"; do + if [ "$RUNNER_OS" = Linux ]; then + nix develop .#android --command just ffi moq-api "$target" + else + just ffi moq-api "$target" + fi + done + env: + TARGETS: ${{ matrix.targets }} + + - name: Upload + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: ffi-api-${{ runner.os }} + path: ffi/target/moq-api + if-no-files-found: error + + ffi: + name: Export moq-net to C + needs: ffi-api + runs-on: ubuntu-24.04-arm + timeout-minutes: 60 + + steps: + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - uses: ./.github/actions/nix + + - name: Download + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + pattern: ffi-api-* + path: ffi/target/moq-api + merge-multiple: true + + # moq's pub API at the pinned moq revision on every target moq ships, merged into one + # binding, which fails on an item two targets define differently; built for the host, + # and driven from each language. + - name: Export + run: nix develop --command just ffi moq + + # Longer random protocol scripts through the C ABI and each binding, against the + # model of what each step returns; the gate runs fewer. + - name: Protocol + run: nix develop --command just ffi protocol + + # What exports, and every refusal, ranked. + - name: Census + run: nix develop --command just ffi census + + - name: Summarize + run: awk 'FNR == 1 { refused = 0 } /^## Refused items/ { refused = 1 } !refused' ffi/target/census/*.md >> "$GITHUB_STEP_SUMMARY" + + - name: Upload + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: ffi-census + path: ffi/target/census + + # The C++ header again with Clang, at each standard and with exceptions and RTTI on + # and off. C stays GCC's, so the export the steps above built stays fresh. + - name: Clang + run: nix develop .#clang --command bash -c 'export CC=gcc; just ffi test cpp && just ffi moq-cpp' + + # Every sampled type shape round-tripped in every language: the fixed set, then shapes + # drawn from the day's seed, which a failure names to reproduce it. The gate runs a + # subset. A job of its own, since it takes as long as the export's. + ffi-shapes: + name: Shapes in every language + runs-on: ubuntu-24.04-arm + timeout-minutes: 60 + + steps: + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - uses: ./.github/actions/nix + + - name: Shapes + run: nix develop --command just ffi shapes + + # The pinned corpus of popular crates, each censused, exported through a facade, and + # bound in every language: a panic, an error, or a binding that does not build fails it. + # Their build scripts run here, on a runner of its own holding no secret. + ffi-corpus: + name: Export the crate corpus (${{ matrix.shard }}/4) + runs-on: ubuntu-24.04-arm + timeout-minutes: 120 + strategy: + fail-fast: false + matrix: + shard: [1, 2, 3, 4] + + steps: + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - uses: ./.github/actions/nix + + - name: Corpus + run: nix develop --command just ffi corpus + env: + CORPUS_SHARD: ${{ matrix.shard }}/4 + + - name: Summarize + if: ${{ !cancelled() }} + run: cat ffi/target/tmp/corpus-${{ matrix.shard }}-of-4/report.md >> "$GITHUB_STEP_SUMMARY" + + # The api fixture's web test in headless Chromium, Firefox, and WebKit, which only the bench shell + # carries: a job of its own, so a browser's failure hides no other result. + ffi-web: + name: Web binding in browsers + runs-on: ubuntu-24.04-arm + timeout-minutes: 60 + + steps: + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - uses: ./.github/actions/nix + + - name: Browsers + run: nix develop .#bench --command just ffi browsers + + # The api fixture's C and C++ scripts against glue built under AddressSanitizer and + # ThreadSanitizer, and its C ABI driven from Rust under Miri. + ffi-sanitize: + name: Export to C under sanitizers and Miri + runs-on: ubuntu-24.04-arm + timeout-minutes: 60 + + steps: + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - uses: ./.github/actions/nix - name: Sanitize run: nix develop .#sanitize --command just ffi sanitize - # The C++ header with the compilers the job above lacks, through the same checks, the # Python on the platforms the job above lacks, and on macOS the Swift with Apple's # toolchain. + ffi-cpp: + name: Export moq-net to C++ (${{ matrix.name }}) + runs-on: ${{ matrix.os }} + timeout-minutes: 90 + strategy: + fail-fast: false + matrix: + include: + - name: MSVC + os: windows-latest + - name: Apple Clang + os: macos-latest + defaults: + run: + shell: bash + + steps: + # ffi/rust-toolchain.toml links to ts/'s. + - name: Symlinks + if: runner.os == 'Windows' + run: git config --global core.symlinks true + + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + # No Nix: its dev shell would replace the system compiler under test. The runner's + # rustup installs rust-toolchain.toml's channel. + - name: Install just + uses: taiki-e/install-action@3a3daafd3b7f23b8f65d9f5ba2db203fb59b79e2 # v2.90.2 + with: + tool: just + + # What a developer prompt sets for cl. VCINSTALLDIR stays unset, so rustc still finds + # its linker itself rather than Git's link.exe on PATH. + - name: MSVC + if: runner.os == 'Windows' + shell: pwsh + run: | + $vs = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath + & "$vs\Common7\Tools\Launch-VsDevShell.ps1" -Arch amd64 -HostArch amd64 -SkipAutomaticLocation + foreach ($name in 'INCLUDE', 'LIB', 'LIBPATH', 'PATH') { + "$name=$((Get-Item "env:$name").Value)" >> $env:GITHUB_ENV + } + + - name: Test + run: just ffi test cpp + + # The Python, on the runner's CPython, which Windows names `python`: its proactor + # loop reads wakes through a task rather than a reader callback. + - name: Python + run: just ffi test python + env: + PYTHON: ${{ runner.os == 'Windows' && 'python' || 'python3' }} + + - name: Export + run: just ffi moq-cpp + + # The Swift through the checks the merge gate runs with nixpkgs' Swift on Linux, then + # moq's session, reusing the builds above. + - name: Swift + if: runner.os == 'macOS' + run: just ffi test swift && just ffi moq-swift + + # The Kotlin on ART under CheckJNI, shrunk by R8 as an app shrinks it, and the library's + # abort messages and 16 KB alignment. x86_64, as moq's Android build: + # this image ships the Android SDK and NDK, and its KVM runs an x86_64 emulator at speed. + ffi-android: + name: Export to Kotlin on Android + runs-on: ubuntu-24.04 + timeout-minutes: 60 + + steps: + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - uses: ./.github/actions/nix + + - name: Enable KVM + run: | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules + sudo udevadm control --reload-rules + sudo udevadm trigger --name-match=kvm + + # The oldest API level moq's Android library supports, then the one it compiles + # against. The second reuses the first's builds. + - name: API 24 + uses: reactivecircus/android-emulator-runner@a421e43855164a8197daf9d8d40fe71c6996bb0d # v2.38.0 + with: + api-level: 24 + arch: x86_64 + script: nix develop .#android --command just ffi android + + - name: API 35 + uses: reactivecircus/android-emulator-runner@a421e43855164a8197daf9d8d40fe71c6996bb0d # v2.38.0 + with: + api-level: 35 + arch: x86_64 + script: nix develop .#android --command just ffi android + + # A 32-bit ABI, as moq's armv7 build is, whose pointers and usize are half a long: + # x86, which this runner's KVM runs at speed. + - name: API 24, 32-bit + uses: reactivecircus/android-emulator-runner@a421e43855164a8197daf9d8d40fe71c6996bb0d # v2.38.0 + with: + api-level: 24 + arch: x86 + script: nix develop .#android --command just ffi android + + # An image whose kernel pages by 16 KB, as Google Play requires of 64-bit libraries from + # 2027-02-01: the library must load there, and its segments must align to that. + - name: API 35, 16 KB pages + uses: reactivecircus/android-emulator-runner@a421e43855164a8197daf9d8d40fe71c6996bb0d # v2.38.0 + with: + api-level: 35 + target: google_apis_ps16k + arch: x86_64 + script: | + test "$($ANDROID_HOME/platform-tools/adb shell getconf PAGE_SIZE | tr -d '\r')" = 16384 + nix develop .#android --command just ffi android + + ffi-bench: + name: Bench the bindings + runs-on: ubuntu-24.04-arm + timeout-minutes: 90 + + steps: + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - uses: ./.github/actions/nix + + # The binding benchmark's tables go in the run's summary: no threshold fails the job. + - name: Bench + # Named, so a failing bench fails the pipe. + shell: bash + run: nix develop .#bench --command just ffi bench | tee -a "$GITHUB_STEP_SUMMARY" + + census: + name: Census moq-net and kio + runs-on: ubuntu-24.04-arm + timeout-minutes: 60 + + steps: + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - uses: ./.github/actions/nix + + # Every construct translation refuses, at the pinned moq revision. + - name: Census + run: nix develop --command just ts census + + # The ranked tables: the spans would pass the summary's size limit. + - name: Summarize + run: awk 'FNR == 1 { spans = 0 } /^## Spans/ { spans = 1 } !spans' ts/target/census/moq-net.md ts/target/census/model.md ts/target/census/kio.md >> "$GITHUB_STEP_SUMMARY" + + - name: Upload + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: census + path: ts/target/census + + # Every driver on the newest nightly rust-overlay names, so the next bump's breaks are + # known before it starts. It fails no merge and opens no issue: the report waits on + # every job but this one. Each module runs after another's failure. + canary: + name: Newest nightly + runs-on: ubuntu-24.04-arm + timeout-minutes: 90 + continue-on-error: true + + steps: + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - uses: ./.github/actions/nix + + - name: Toolchain + id: toolchain + run: | + channel=$(sh/canary.sh) + echo "Canary on \`$channel\`" >> "$GITHUB_STEP_SUMMARY" + + - name: Driver + if: ${{ !cancelled() && steps.toolchain.outcome == 'success' }} + run: nix develop --command bash -c 'just driver check && just driver test' + + - name: Export + if: ${{ !cancelled() && steps.toolchain.outcome == 'success' }} + run: nix develop --command bash -c 'just ffi check && just ffi test' + + - name: Go + if: ${{ !cancelled() && steps.toolchain.outcome == 'success' }} + run: nix develop --command bash -c 'just go check && just go test' + + - name: TypeScript + if: ${{ !cancelled() && steps.toolchain.outcome == 'success' }} + run: nix develop --command bash -c 'just ts check && just ts moq && just ts test' + + # A scheduled run's failure opens one issue, or comments on the one still open, and a + # pass closes it, so a suite only this workflow runs cannot fail unseen. Only the + # schedule, which runs main, gets the write token: a dispatch can run any branch. + report: + name: Report + needs: [bindings, gate, ts, bench, ffi-api, ffi, ffi-shapes, ffi-corpus, ffi-web, ffi-sanitize, ffi-cpp, ffi-android, ffi-bench, census] + if: ${{ !cancelled() && github.event_name == 'schedule' }} + runs-on: ubuntu-24.04 + timeout-minutes: 5 + permissions: + issues: write + + steps: + - name: Issue + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + FAILED: ${{ contains(needs.*.result, 'failure') }} + RUN: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + SHA: ${{ github.sha }} + run: | + title="The nightly fails" + issue=$(gh issue list --state open --search "\"$title\" in:title" --json number,title --jq ".[] | select(.title == \"$title\") | .number" | head -n 1) + if [ "$FAILED" = true ]; then + body="[This run]($RUN) failed at $SHA." + if [ -n "$issue" ]; then + gh issue comment "$issue" --body "$body" + else + gh issue create --title "$title" --body "$body" + fi + elif [ -n "$issue" ]; then + gh issue close "$issue" --comment "[This run]($RUN) passed at $SHA." + fi diff --git a/quest/m1/ffi-proofs/arm-sanitizers.md b/quest/m1/ffi-proofs/arm-sanitizers.md deleted file mode 100644 index 1a3e9d011..000000000 --- a/quest/m1/ffi-proofs/arm-sanitizers.md +++ /dev/null @@ -1,28 +0,0 @@ -# [S] The nightly sanitizers run on the arm runner - -## Goal - -The nightly's `ffi-sanitize` job passes on `ubuntu-24.04-arm`. Today `api_asan`, -`api_tsan`, and `api_swift_tsan` fail there on their first program run, which prints -nothing. Each one passes on x86_64 Linux. - -## Plan - -Decided with the maintainer on 2026-11-19, in the pick of [#891](https://github.com/kixel-ai/rust2/pull/891): ✅ kept (rejected: dropping it). - -Found by the checkers quest -([kixel-ai/rust2#891](https://github.com/kixel-ai/rust2/pull/891)). The job has failed on -every nightly since it was added on 2026-11-14, for example -[run 44339014570](https://github.com/kixel-ai/rust2/actions/runs/44339014570). Valgrind, -Miri, Go's race detector, and the debug CPython in the same job pass. - -A failed run now names its exit status (`check` in `ffi/tests/fixtures.rs`). Read that -first. The leading suspect is the runner kernel's ASLR entropy (`vm.mmap_rnd_bits`): it -breaks the sanitizer runtimes' shadow layouts, and the common fix lowers it with `sysctl` -in the job. The other suspect is a mismatch between nixpkgs clang's compiler-rt and the -nightly rustc's instrumentation on aarch64. Fix the cause, not the symptom. Running on -x86_64 instead would hide it. - -## Hosts - -- linux - the failure is on aarch64 Linux; reproduce on an arm64 Linux host or the runner From f889ee6164007305269a2ad2a4a86c093f55ddff Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 20 Nov 2026 07:59:47 -0800 Subject: [PATCH 14/14] chore(quest): finish arm-sanitizers and the proofs epic Co-Authored-By: Claude Sonnet 5.5 --- ffi/README.md | 3 +++ quest/m1/README.md | 3 +-- quest/m1/ffi-export/README.md | 3 +-- quest/m1/ffi-proofs/README.md | 19 ------------------- 4 files changed, 5 insertions(+), 23 deletions(-) delete mode 100644 quest/m1/ffi-proofs/README.md diff --git a/ffi/README.md b/ffi/README.md index 3ebe7c326..341d630af 100644 --- a/ffi/README.md +++ b/ffi/README.md @@ -1763,6 +1763,9 @@ and cgocheck2, and `tests/api.py`'s checks on a debug build of the newest CPytho blocks end where they began; and it drives the C ABI from `tests/miri/api.rs` and the protocol scripts from `tests/miri/protocol.rs` under Miri with strict provenance. The protocol scripts' C driver runs under each sanitizer too. +On aarch64 the glue builds without outline atomics (`-Ctarget-feature=-outline-atomics`): the +instrumented `compiler_builtins` would answer the runtime's own atomics, before its shadow +exists, and crash it in `__asan_init`. moq's crates export through `target/moq-ffi`, an empty library on each that `just ffi moq` writes in place of moq-ffi's remainder. The export serves the host and each target `just ffi moq-api` staged in `target/moq-api` from the same moq sources, and fails on a diff --git a/quest/m1/README.md b/quest/m1/README.md index 4e3352e61..44e5a3106 100644 --- a/quest/m1/README.md +++ b/quest/m1/README.md @@ -25,7 +25,6 @@ hold moq's pin open; the epic retired on 2026-11-16 once its children landed. Re Decided with the maintainer on 2026-11-18, in the per-language audit of the exporter's bindings and the translators: ✅ its findings join m1 where moq's switch uses them. Breaking changes are children of [the exporter epic](/quest/m1/ffi-export/README.md) and land as -soon as possible; the rest are the [proofs](/quest/m1/ffi-proofs/README.md), -[speed](/quest/m1/ffi-speed/README.md), [rule cost](/quest/m1/ffi-rules/README.md), and +soon as possible; the rest are the [speed](/quest/m1/ffi-speed/README.md), [rule cost](/quest/m1/ffi-rules/README.md), and [packaging](/quest/m1/ffi-packaging/README.md) epics, and the fixes and additions at this milestone's top. Rejected: packaging in m2. diff --git a/quest/m1/ffi-export/README.md b/quest/m1/ffi-export/README.md index 2126ec296..d379b6bfe 100644 --- a/quest/m1/ffi-export/README.md +++ b/quest/m1/ffi-export/README.md @@ -101,8 +101,7 @@ Decided with the maintainer on 2026-11-18, in the per-language audit: Kotlin (landed), Python (landed), Dart (landed), and docs. Rejected: only the surface lock holding the pin; all of them after the pin. - ✅ Work that changes no generated API, or only adds to it, stays out of this epic, as - decided on 2026-11-12: [proofs](/quest/m1/ffi-proofs/README.md), - [speed](/quest/m1/ffi-speed/README.md), [rule cost](/quest/m1/ffi-rules/README.md), + decided on 2026-11-12: [speed](/quest/m1/ffi-speed/README.md), [rule cost](/quest/m1/ffi-rules/README.md), [packaging](/quest/m1/ffi-packaging/README.md), ordering and stream adapters (landed), with [Swift streams of noncopyable objects](/quest/m1/swift-async-reader.md). - Dropped: a per-function contract in place of the whole-header hash, since moq links diff --git a/quest/m1/ffi-proofs/README.md b/quest/m1/ffi-proofs/README.md deleted file mode 100644 index 2a1b2cd43..000000000 --- a/quest/m1/ffi-proofs/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# Prove the exporter on more inputs - -## Goal - -[rust2-ffi](/ffi/README.md) is checked against inputs and call sequences no one wrote by -hand: stock crates, a wider shape sample, random protocol sequences, and every language's -own checkers. It completes when every child has merged. - -## Plan - -Decided with the maintainer on 2026-11-18, in the per-language audit: ✅ all four proofs -the audit proposed are kept (rejected: any subset). Existing proofs stay: differential -transcripts against native Rust in every language, seeded shape round-trips, ASan and TSan, -Go's race detector, Miri, and loom on `rt/borrow.rs` and the hold counts. - -This epic changes no generated API, so it does not hold moq's pin -([the exporter epic](/quest/m1/ffi-export/README.md#plan)). Considered and dropped by the -audit: Kani, since the runtime's `unsafe` is FFI and concurrency, where Miri and loom fit -better; and mutation testing of the generators, since every mutant reruns eight languages.