Skip to content

Pre-release fixes: std len casts, no host sample, AEAD (#1054), races (#985), unit elision (#723), typed extern var (#2335) - #2803

Merged
ehartford merged 6 commits into
mainfrom
std-len-casts
Oct 29, 2026
Merged

ehartford merged 6 commits into
mainfrom
std-len-casts

Conversation

@ehartford

@ehartford ehartford commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Battery GREEN on 887e0bb.

Eric Hartford added 6 commits October 29, 2026 01:08
Range bounds now join at the lossless widening (§4.2.6), and isize and
i32 widen into i64 at any demand, so these casts said nothing:
- build.w: str.slice bounds (as i64) and the https_fetch source's
  0..len() as i32 loops, which a literal start always allowed.
- cfg/stackify.w: stackify_bool_list took its count as i32, which forced
  three len() as i32; a count is an isize (D108). Its counting while loop
  is a for.

The rest stay: C ABI widths (c_int, c_uint, u64), stores into i32 fields
and parameters, and if-arms joining isize with i64 (D125).
The darwin runtime ran /usr/bin/sample on every child past its timeout
(#2249) before killing it: a host command in the toolchain (Eric,
2026-10-28: the compiler and its build are bootstrapped), seconds of
delay, a 'timeout: child N sampled' note on the waiting program's stderr,
and a /tmp file per child (135 had piled up since 2026-10-24). A build
that stops its lanes on an early return took the same path, so a
deliberate stop read as a hang.

The hang route in deep-debugging-tools.md is now the debugger: rerun the
timed-out command and `lldb --batch -p <pid> -o "bt all"` (run as
written: it named the spinning function and line).

Test: behav_process_timeout_stops_child, a probe that times out a
sleeping child; the installed compiler prints the sample note, stage1
nothing.
…s tag is RFC 8439's (#1054)

The AEAD's one entry point was a private raw-pointer unsafe fn, so no
program could call it. Worse, it never produced RFC 8439 tags: it fed the
AAD and its zero padding to poly1305_update in two calls, and
poly1305_update closes a short final block (0x01 marker) at the end of
every call, so a partial last block went in marked and short instead of
zero-padded to 16. Poly1305 alone matches RFC 8439 §2.5.2; the AEAD's
ciphertext matched §2.8.2 and its tag did not (36ae32c8… for 1ae10b59…).

- chacha20_poly1305_seal(key, nonce, aad, plaintext) -> Result[List[u8],
  AeadError]: ciphertext then tag. chacha20_poly1305_open checks the tag
  in constant time before decrypting. Both take the buffer they turn into
  their result and work in place (D110: the callee stores it); key, nonce
  and aad are observed.
- AeadError: KeyLength, NonceLength, Forged.
- chacha20_crypt and poly1305_update take their length as an isize (D108),
  which retires their callers' len() as i32.

Test: behav_1054_chacha20_poly1305_rfc8439, RFC 8439 §2.8.2 both ways, a
flipped ciphertext bit, other aad, a short input, and bad key and nonce
lengths; clean under the debug allocator.
…bal (#985)

std.random's xorshift state was a plain var that every draw read and wrote.
Threads drawing at once read one state and drew the same value: eight OS
threads drawing 20000 each got 10219 duplicates under the installed
compiler. xorshift64 repeats nothing within its period, so each duplicate
is a lost step. std.sys filled five globals behind a plain bool on first
call, so first calls from two threads both measured and raced the writes.

§9.1c: shared mutable globals are Sync types.
- rng_state is a global Atomic[i64]; a draw is one compare-exchange from
  the state it read to its successor, and the first draw seeds it.
  seed and seed_now store.
- std.sys keeps its facts in a global Mutex[Option[SysFacts]]; the first
  caller measures under the lock. The _bw_sink global was dead (the read
  pass's barrier is inline asm on a local) and is gone.

The issue's 0 - v overflow went with #2279's rewrite (wrapping draws).

Test: behav_985_random_draws_race_free (installed: 10219 duplicate draws;
stage1: 160000 distinct, five runs out of five).
§4.8 unit elision: a single expected Unit argument may be omitted, and its
first example is unwrap_or(). Ok(), Some(), a user fn's Unit parameter and
an Ok() pattern already elided; unwrap_or() on Option[Unit] or
Result[Unit, E] was refused ('expects exactly one argument') because
method_expected_arg_type leaves unwrap_or's default untyped on purpose (a
given default is a join input). With no argument there is no join, so the
method path's elision step reads the payload type for unwrap_or itself.
Option[i32].unwrap_or() is still refused.

spec_ss04_8_unit_elision passes (5 tests); its known-issue marker is gone.
An `extern var` naming another module's global resolved when the owner
was untyped and was refused when it stated its type ('symbol ... is not
visible from this module'). The frontend dropped an `extern var` from the
user and root tiers when its name, mutability and type text matched a
declaration in the tier (8a434e0, for migrated modules that each
declared the same global). An untyped owner has no type text, so its
`extern var` survived; a typed one's was dropped, and with it the
declaring module's grant (has_extern_var_decl), so the owner's global,
private to its own package (D100), was not visible.

Sema merges an `extern var` with its owner (the #113 test), so the user
and root tiers keep the declaration. The prelude tier's filter is
unchanged. The regex tests, which compile the migrated pcre2 from source
on stage1, pass.

Test: issue2335_extern_var_typed_redeclaration (installed: not visible;
stage1: ok).
@ehartford
ehartford added this pull request to stack #2806 October 29, 2026 06:29
@ehartford ehartford changed the title std len casts Pre-release fixes: std len casts, no host sample, AEAD (#1054), races (#985), unit elision (#723), typed extern var (#2335) Oct 29, 2026
@ehartford
ehartford marked this pull request as ready for review October 29, 2026 06:29
@ehartford
ehartford merged commit d740b6b into main Oct 29, 2026
@ehartford
ehartford deleted the std-len-casts branch October 29, 2026 06:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant