Repository navigation
Checker: tuple call as scalar argument, return value count; std.os sandbox checks; two flaky tests - #3880
Merged
Conversation
A call that returns several values, written straight into an argument whose parameter takes one value (`takes(list.get(xs, 0))`, `spec.expect_str(pair())`, or as a UFCS receiver, `pair().takes()`), passed the checker and failed in the C compiler: "passing '_tuple_ptr_string' to parameter of incompatible type 'const char *'". reject_tuple_argument already refused a NAME bound to the tuple, but left a call to "the callee's own rules", and nothing else looked. A multi-value return is never spread over parameters (`f(pair())` for a two-parameter `f` is an arity error), so the call form is the same mistake. It is now E0200 at the argument, naming the call and the fix (destructure it first), for user functions, module functions and externs alike. A `fn`/wildcard parameter is left alone. Test: tuple_argument_reject gains the call, module-call and UFCS cases, and a destructured list.get_string that still runs; the new cases fail on main (aetherc accepted the program). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
check_return_values let a multi-value `return` through whenever its
count differed from the result type's (`rt->tuple_count !=
ret->child_count`, or a result that is not a tuple at all), and codegen
then built the value in the shape of the first `return`:
pick(ok: int) -> {
if ok == 0 { return 0, "" }
return 41, "", 3 // third value dropped, C warning only
}
`return 0` followed by `return 41, 1` returned a tuple from an int
function (a C compiler error); `return 0, 0, 0` followed by
`return 41, 1` zero-filled the last value. The value-type side of a
differently shaped early return (an early `return 0, 0, 0` ahead of a
return of 64-bit values) was already the narrowing error (#2782); the
count side was not checked at all.
Now E0200 at the `return`: "'pick' returns (int, string) (inferred from
its first `return`), but this `return` gives 3 values", with a hint to
give every `return` the same number of values or write the result type.
The same for a written result type.
Test: return_type_check gains one-then-two, two-then-three,
three-then-two and a written (int, string) returning three; all four
were accepted on main.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
os_which checked `env PATH` and then access(2)'d each `<dir>/<name>`
on it unchecked, so code in a sandbox with no file-system grant learned
where any program on PATH was installed. os_getcwd_raw checked nothing
and gave the path of a directory the caller may not read. Every other
std call that tells what is at a path is an fs_read (fs.exists,
file_stat, realpath, ...; docs/containment-sandbox.md).
Each candidate os.which tries (POSIX: the name with a slash, `./name`
for an empty PATH entry, `<dir>/name`; Windows: every PATH and PATHEXT
combination) is now an fs_read of that path, a refused one skipped as
if absent. os.getcwd checks fs_read on the directory getcwd(3) gives
and returns "" when refused. The containment doc lists both.
Behaviour change for sandboxed code: os.which needs fs_read on the
directory that holds the program (grant_fs_read("/usr/bin/*")), not
only `env PATH`.
Test: tests/regression/test_os_which_getcwd_sandbox.ae, which on main
fails with "os.which found '/bin/sh' with no fs_read grant".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The demonstration run (BROKEN_CANCELLER=1, a canceller that closes the
connection's descriptor by number) must show the race check catching
it, and grepped only for "a decoy was disturbed". On a loaded host the
broken close lands on a decoy while it is still dialling, the number
already the decoy's, and the round fails as "decoy dial: [connect
failed]" first: the check caught it, and the test reported that it had
not ("the race check did not catch a canceller that closes by number").
Seen in a 12-way parallel `make test-ae` on macOS; it passes alone.
Both forms now count as caught in the demonstration run. The plain run,
where any decoy failure is a real one, is unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The s_server cases computed a port from the shell's pid and the case name and retried on a bind failure. In a parallel `make test-ae` on FreeBSD one case (-ciphersuites TLS_CHACHA20_POLY1305_SHA256) failed with the client's "connect failed" while s_server had printed ACCEPT and saw no connection; alone it passes. A computed port can be one another test is using: s_server binds the wildcard with SO_REUSEADDR, which FreeBSD lets coexist with another socket's 127.0.0.1 bind of the same port, so the client can reach the other listener instead. s_server now gets `-accept 0`, and the port is read from its "ACCEPT 0.0.0.0:<port>" line: the kernel's choice, free by construction. Checked on macOS (OpenSSL 4.1) and FreeBSD (3.5). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…andboxes The Windows os_getcwd_raw is a function of its own and had not been given the fs_read check the POSIX one got in this batch, so a sandbox with no fs_read grant was still told the working directory (Windows/UCRT64, MSYS2, and Wine: "os.getcwd told 'Z:\...' with no fs_read grant"). test_os_which_getcwd_sandbox never freed its two grant lists; the env-only one was reported (LSan exit 23, macOS leaks: 6 leaks, 192 bytes). Checked: macOS leaks 6 -> 0; the Windows build under Wine fails as CI did before and passes after. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…see the close
The per-IP round holds two connections against a limit of two, closes
the first, slept a fixed 300 ms, and then expected a fourth connection
to be served. It failed now and then on the Windows / GCC (MSYS2) job
("after one closed 503"), on main as well as on PRs.
The server is not wrong. The address's slot is given back in conn_close,
on a worker: the parking lot's poller sees the client's FIN, hands the
connection to a pool worker, the worker reads the end and closes. That
is two thread hand-offs, and the server never promised them within any
time. Measured on the Windows 11 lab VM with the probe run 8 at a time
beside 16 busy loops (a loaded runner), the time from the client's close
to the server's close was median 47-62 ms, p99 250-282 ms, max 344 and
516 ms: past 300 ms now and then, which is exactly the 503 CI saw. A
fourth connection arriving before then is correctly refused.
So the round now waits for the observable condition instead of a sleep:
on a worker-path server, the on_conn_close hook (which runs after the
address's count has gone down); on the proxy event loop, which has no
such hook, its live connection count down to the one still held. The
wait is bounded at 5 s and the round fails if the close is never seen,
so a server that stopped giving slots back still fails it. The note
reports how long the close took to be seen.
Windows 11 VM, SLOW_PROBE_ONLY=perip under that load: before, 4 of
1200 per-IP rounds failed (0.33%); after, 0 of 1200. Unloaded, 0 of 200
either way. The whole test passes on Windows 11, macOS and FreeBSD 15.1
(ghostbsd), the last two including the event-loop round.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Commits: two checker holes where a wrong program reached the C compiler (or compiled and returned the wrong value), a sandbox gap in
std.os, and flaky tests fixed at the root. Each fix has a regression test that was run against main and failed there before it passed with the fix.Commits
1a0d7eb checker: refuse a tuple-returning call passed as a scalar argument
ae checkand then failed in the C compiler:passing '_tuple_ptr_string' to parameter of incompatible type 'const char *'.reject_tuple_argumentcaught a name bound to the tuple, but skipped calls.spec.expect_str(list_get(av, 0)),takes(list.get(xs, 0)),takes(pair()),pair().takes()(UFCS).f(pair())for a two-parameterfis already an arity error), so the call form is now E0200 at the argument. The message names the call and says to destructure it first.fnand wildcard parameters are not affected.tests/integration/tuple_argument_rejectadds the user-function, module-function and UFCS cases, plus a destructuredlist.get_stringthat still runs. On main, aetherc accepted all three cases.a6a32d7 checker: a multi-value return must match the result's count
check_return_valuesaccepted a multi-valuereturnwhose count differed from the result type, and codegen then used the shape of the firstreturn.return 0followed byreturn 41, 1failed in C.return 0, ""followed byreturn 41, "", 3silently dropped the third value (only a C warning about excess initializers).return 0, 0, 0followed byreturn 41, 1filled the missing value with zero. The value-type side of a differently shaped early return was already the narrowing error (A return value that does not fit the written result type is accepted and fails in C #2782); nothing checked the count.return, e.g. "'pick' returns (int, string) (inferred from its firstreturn), but thisreturngives 3 values". This covers inferred and written result types. For an optional tuple result (-> (int, int)?) it counts the tuple's values, sotest_optional_tuple_returnstill passes.tests/integration/return_type_checkadds five cases: one-then-two, two-then-three, three-then-two, a written(int, string)returning three, and an optional(int, int)?returning three. On main all five were accepted.a380286 std.os: check os.which candidates and os.getcwd against the sandbox
os_whichchecked onlyenv PATH, then calledaccess(2)on every<dir>/<name>without a sandbox check. So code in a sandbox with no file-system grant could find out where any program on PATH was installed.os_getcwd_rawchecked nothing.fs_readof its path (POSIX and Windows/PATHEXT). A refused candidate is skipped as if absent, the same asfs.exists.os.getcwdneedsfs_readon the directory and returns "" when refused, the same asfs.realpath(".").docs/containment-sandbox.mdlists both.os.whichnow needsfs_readon the program's directory (e.g.grant_fs_read("/usr/bin/*")), not justenv PATH.tests/regression/test_os_which_getcwd_sandbox.ae. On main it fails with "os.which found '/bin/sh' with no fs_read grant".e828732 tests: tcp_deadline_cancel accepts a decoy dial the broken canceller hit
BROKEN_CANCELLER=1) has to show that the race check catches a canceller that closes a descriptor by number. On a loaded host, the broken close can land on a decoy while it is still dialling, so the round fails as "decoy dial: [connect failed]" instead of "a decoy was disturbed". The check did catch it, but the shell test reported that it had not. This happened in a 12-way parallelmake test-aeon macOS. The demonstration run now accepts both forms; the plain run is unchanged.68cd10e tests: external_psk lets openssl s_server pick its own port
make test-aeon FreeBSD, one case failed: the client reported "connect failed" while s_server had printed ACCEPT and saw no connection. The likely cause is a collision with a port another test held on 127.0.0.1, which s_server'sSO_REUSEADDRwildcard bind does not refuse on FreeBSD. The test now passes-accept 0and reads the kernel's chosen port from theACCEPTline. Checked on macOS (OpenSSL 4.1) and FreeBSD (3.5).b1854d9 std.os: getcwd checked under fs_read on Windows too; test frees its sandboxes
os_getcwd_rawis a separate function and had not been given thefs_readcheck that a380286 added on POSIX, so a sandbox with nofs_readgrant was still told the working directory (Windows UCRT64, MSYS2 and Wine). It now checks it too.test_os_which_getcwd_sandboxfreed neither of its two grant lists (LSan exit 23; macOSleaks6 leaks, 192 bytes). It frees both now.leaks6 to 0; the Windows build under Wine fails as CI did before the fix and passes after.02b47ec tests: http_server_slow_clients per-IP round waits for the server to see the close
round[per ip ...]: ... after one closed 503 FAILED.conn_closeon a pool worker, after the parking lot's poller sees the FIN and hands the connection over: two thread hand-offs with no promised bound. On the Windows 11 VM under load (probe 8-way beside 16 busy loops) close-to-release took median 47-62 ms, p99 250-282 ms, max 344 and 516 ms. A connection arriving before that is correctly refused, so the server is not wrong; the test's timing was.on_conn_closehook on the worker path (it runs after the count goes down), the event loop's live connection count on the loop round. The round still fails if the close is never seen.Lane results
CC=gcc make cigreen: C unit tests 788/788, its.aesweep 2396 passed / 0 failed / 20 skipped. Thenmake test-ae: 2397 passed / 0 failed / 19 skipped.gmake test786/786.gmake test-ae: 2381 passed / 1 failed / 34 skipped. The one failure wascrypto_tls13_external_psk(the s_server port collision above). It passed when run alone, and with 68cd10e it passed twice more there.make test-ae2360 passed / 0 failed / 56 skipped (all commits except 68cd10e, which only touches that test; passes alone on macOS).make check-docs,make check-changelogandae fmtare clean. There is one changelog fragment for each of the three fixes.🤖 Generated with Claude Code