Go's Memory Safety: The Hidden Danger of Thread Unsafety

2025-07-25

This article challenges the common understanding of memory safety in Go. The author argues that simple memory safety (e.g., preventing out-of-bounds access) isn't sufficient for robust programs; true safety lies in avoiding undefined behavior (UB). A Go program example demonstrates how data races can lead to UB and crashes, even without using `unsafe` operations. The author contends that Go's handling of data races is not strict enough, contradicting its claims of memory safety, making Go programs more vulnerable to security exploits. The conclusion emphasizes that language safety isn't binary but understanding a language's safety guarantees and trade-offs is crucial.

Read more
Development Data Race

Pointers Are Complicated II: The Subtle Bugs in LLVM Optimizations

2025-02-02

This post delves into the importance of precise semantics for compiler intermediate representations (IRs), especially for languages like C, C++, and Rust that allow unsafe pointer manipulation. The author demonstrates how a sequence of three seemingly correct LLVM compiler optimizations can lead to incorrect program behavior. The root cause is pointer provenance – the extra information embedded in a pointer beyond its memory address, detailing how it was computed. This necessitates a more precise LLVM IR specification, including a precise definition of undefined behavior (UB). Treating compiler IRs as standalone programming languages with rigorous specifications is key to resolving such issues.

Read more
Development pointer semantics