hn.today

Valen's Memory Safety: A New Kind of Borrow Checking

verdagon.dev125 points77 comments
Screenshot of Valen's Memory Safety: A New Kind of Borrow Checking

Valen introduces a new flexible borrow checker built on group borrowing: the compiler records the exact path a reference points to and uses that information to enforce memory safety by forbidding use-after-free instead of insisting on the traditional shared-or-exclusive (shared-xor-mutable) rule. That single “borrow” kind can coexist with reference counting, generational references, and Rust interop because function signatures can express which paths a call may invalidate. The design combines Vale’s generational/region ideas with group-borrowing twists so the checker can reason about whole-object graphs, let multiple aliases exist, and still prove safety at compile time.

Practically, this permits patterns that most borrow checkers reject: multiple local mutable aliases to the same object that can all write, parameters that point inside other parameters, multiple function parameters aliasing the same target, rollback/scope-guard mutations, and other real-world idioms. The checker encodes paths and wildcard descendant paths to track and communicate invalidations, catching use-after-free at compile time with no extra runtime checks in many cases (subject to practical caveats). The approach has already influenced several language designs and aims to make zero-cost, more permissive compile-time memory safety broadly practical.

Read on verdagon.dev77 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Security

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.