You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Checker misses a global mutated inside a callee while a view of it is live (§9.1c globals are places, §21.1 Rule 1) #1819
var G: Vec[str] = Vec.new()
fn grow():
for i in 0..64: G.push(f"item{i}")
fn show(r: &str):
grow()
print(r)
fn main:
G.push("first" ++ "!")
show(G[0])
with check accepts both (fix-lang stage1; the installed compiler).
Spec
§9.1c: "Globals are places; §21.1's access rules apply." In each program a view of G's storage is live across a call whose callee mutates G — §21.1 Rule 1's invalidation. The same program over a local is refused ("cannot mutate s while r is a live view into it"); the checker does not see a global mutated inside a callee.
What each representation does with it (both read freed memory in one of the two)
&str a pointer to a str header (today): the first program reads G's current header ("wxyz", safe by accident); the second reads the element header out of the Vec buffer grow() reallocated and freed (use-after-free; prints "first!" only because the freed block is intact).
A call whose callee (transitively) writes a global is a write of that global at the call site for §21.1: refused while a view whose origin is that global's storage is live — with the §9.1c global-mutation facts the race proof already collects per global.
Activity
Sema: a local that takes the name of a global its module cannot see i…
CImport: the goto CFG's `fail` is handed copies of the bail globals, …
Sema: a call writes every global its callee writes, so a view of that…
Sema: a call of a bundle function writes every global its bundle expo…
Sema: a dyn call runs every impl of the method in this compilation, s…
Sema: a call through a stored callable runs any callable value of its…
Sema: a str range view carries only its base's origins, so `fn tail(s…
&str is its own {ptr,len} view (ABI v8): returned string slices, stag…
#3026: the #1819/#1827 global-view pins keep a List field — a str fie…
#3026 (D111): an unannotated let of a str place takes the str; a str …