Skip to content

test: scale the adversarial suite's RSS budget to the build - #3073

Merged
chaliy merged 3 commits into
mainfrom
eve/clever-mccarthy-dtjmmh
Dec 4, 2026
Merged

chaliy merged 3 commits into
mainfrom
eve/clever-mccarthy-dtjmmh

Conversation

@chaliy

@chaliy chaliy commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

What changed

The three RSS-measuring tests in adversarial_redteam_stress_tests.rs now read
their ceiling from rss_budget_mib() instead of a hard-coded 256: still
256 MiB on an uninstrumented build, 1 GiB when a sanitizer's shadow map is
present. The failure message also names the budget it broke, so the next
instance explains itself from the log line alone.

No product code changes; nothing about what the tests exercise changes.

Why

The nightly AddressSanitizer legs both failed blackbox_builtin_adversarial_attacks
in run 47263332281 — RSS grew too much during builtin attacks: 53 -> 379 MiB
(interpreter) and 56 -> 395 MiB (execution-plan) — while required CI stayed
green on the same commit.

Nothing leaked. The same workload costs a 49 MiB delta natively (measured in
#3066, each measuring test alone in its process). ASan multiplies it: redzones
around every allocation, plus a 256 MiB default free-list quarantine that holds
freed blocks resident on purpose. A flat 256 MiB ceiling was therefore measuring
instrumentation, not retention — the same native-versus-instrumented divergence
this suite's budgets have hit twice before (nightly #46806775136 on a cap
timeout, run 257 on RLIMIT_AS).

The ceiling moves rather than the assertion: an instrumented run keeps a real
bound at ~3x the measured delta, and the runaway growth these tests exist to
catch is multi-gigabyte against tight_limits() and a 512 KiB filesystem.
Deleting the check on instrumented builds would retire the coverage on the build
most likely to expose a leak.

cfg(sanitize) is still unstable and this suite builds on the pinned stable
toolchain, so the build is detected at runtime: a sanitizer reserves ~14 TiB of
virtual address space for its shadow map at startup (the reservation
knowledge/operations/testing.md already records from the RLIMIT_AS
incident), three orders of magnitude above anything an uninstrumented test
binary maps.

Before / After

  • Nightly AddressSanitizer (interpreter) / (execution-plan) — red on a
    326 MiB and a 339 MiB delta against a 256 MiB ceiling → the same deltas sit
    inside the 1 GiB instrumented ceiling. Verified by dispatching Nightly on
    this branch (link in the thread below).
  • Required CI — unchanged: the uninstrumented ceiling is still 256 MiB and
    the suite's worst native delta is still 49 MiB. cargo test -p bashkit --test adversarial_redteam_stress_tests passes in 4.0s, 10/10.
  • A real regression — still fails: multi-gigabyte growth breaks either
    ceiling, and the message now prints which one.

Risk

  • Low
  • The instrumented ceiling is looser, so a leak between 256 MiB and 1 GiB would
    pass on a sanitized run. It would still fail the identical assertion on every
    required-CI run, where the ceiling is unchanged.
  • Runtime detection is a heuristic over /proc/self/statm virtual size.
    Misdetection can only pick the other constant, never skip the assertion, and
    rss_budget_follows_the_shadow_map pins the threshold against both
    measurements as a plain #[test].

Checklist

  • Tests added or updated
  • Backward compatibility considered

Generated by Claude Code


Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

The three RSS-measuring tests in adversarial_redteam_stress_tests.rs read
their ceiling from rss_budget_mib() instead of a hard-coded 256: still
256 MiB uninstrumented, 1 GiB when a sanitizer's shadow map is present. The
failure message now names the budget it broke.

Both nightly AddressSanitizer legs failed blackbox_builtin_adversarial_attacks
in run 47263332281 (53 -> 379 MiB and 56 -> 395 MiB) while required CI stayed
green on the same commit. Nothing leaked: the same workload costs a 49 MiB
delta natively, and ASan multiplies it with per-allocation redzones plus a
256 MiB default free-list quarantine that holds freed blocks resident by
design. A flat ceiling was measuring instrumentation, not retention.

The ceiling moves rather than the assertion, so an instrumented run keeps a
real bound at ~3x the measured delta while the runaway growth these tests
exist to catch is multi-gigabyte against tight_limits() and a 512 KiB
filesystem. cfg(sanitize) is still unstable and this suite builds on the
pinned stable toolchain, so sanitizer_shadow_present detects the build from
virtual size: a sanitizer reserves ~14 TiB of address space for its shadow
map, three orders of magnitude above anything an uninstrumented test binary
maps. rss_budget_follows_the_shadow_map pins that threshold against both
measurements.

@bashkit-pr-reviewer bashkit-pr-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Test-only change; the per-build RSS budget approach looks sound. Two non-blocking suggestions below.

@bashkit-pr-reviewer

bashkit-pr-reviewer Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Review summary (head ccf7247)

Verdict: All findings resolved; no new issues. This push is exactly the one-word testing.md fix (statm → status), so the docs now match the /proc/self/status reader throughout. No review posted (nothing left to raise).

Findings: P0: none. P1: none. P2: none outstanding — (1) rss_budget_for branch coverage: resolved; (2) page-size assumption: resolved via status reader; (3) testing.md stale statm reference: resolved in this push.

Context read beyond the diff: re-verified testing.md:572-578, the proc_status_mib reader, and the pin test (both budget branches plus Linux-only non-zero guards) at the new head.

Could not review: Nothing — checkout succeeded; no build/test run per workflow (reasoned from code).

Review follow-ups on the per-build RSS budget.

/proc/self/statm counts pages, and the 4 KiB multiplier assumed a page size
the host need not have: on a 16 KiB-page aarch64 kernel every number was a
quarter of the truth, on 64 KiB-page ppc64 a sixteenth. That loosens a ceiling
rather than breaking it, so it would not have announced itself. The reader now
takes VmRSS and VmSize from /proc/self/status, which reports kB and needs no
page size, and the pin test asserts both read non-zero so a silent parse
failure cannot leave the budget assertions passing vacuously.

rss_budget_for takes the virtual-size measurement as an argument and
rss_budget_mib delegates to it, so the pin test reaches both branches:
measuring the live process can only ever exercise the one this build is on,
which let a hardcoded return value pass.

@bashkit-pr-reviewer bashkit-pr-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Both P2s from the last round are resolved. One new nit below.

Comment thread knowledge/operations/testing.md Resolved
The section's first sentence still pointed at /proc/self/statm after the
reader moved to /proc/self/status, two paragraphs above the rule that says
why.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit ccf7247 Commit Preview URL

Branch Preview URL
Dec 04 2026, 09:40 AM

chaliy commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

Verified against the job that was red. Dispatched Nightly on this branch (run 47306908012) — all 10 jobs green, including both legs that failed on main:

Job main (run 47263332281) this branch
AddressSanitizer (interpreter) ❌ RSS grew too much during builtin attacks: 53 -> 379 MiB ✅
AddressSanitizer (execution-plan) ❌ 56 -> 395 MiB ✅

blackbox_builtin_adversarial_attacks, blackbox_shell_parser_expansion_and_traps and concurrent_multi_tenant_hostile_stress_and_canary_isolation all pass under ASan, and rss_budget_follows_the_shadow_map runs there too — so the shadow-map detection is exercised on the instrumented build, not just reasoned about.

Required CI is green on ccf7247 (87/87). One unrelated red along the way: Callback loops (macos-latest) (execution-plan) failed on crates/bashkit-python/tests/test_teardown_determinism.py::test_interpreter_exit_does_not_crash[abandoned-slow-cancel] with callback never cancelled — a 2 s wall-clock wait in the Python binding's teardown test. This diff is one Rust test file and two knowledge docs, with no Python and no library code; Python is green on main across its last 12 runs; it passed on re-run.


Generated by Claude Code

@chaliy
chaliy merged commit 1e75252 into main Dec 4, 2026
109 of 110 checks passed
@chaliy
chaliy deleted the eve/clever-mccarthy-dtjmmh branch December 4, 2026 10:06
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