Cinematic close-up of raw, jagged obsidian shards transforming into perfectly smooth, translucent glass spheres. Neon bl

For decades, the C and C++ community has been locked in a stalemate. We want the raw performance and total control of these languages, but we're tired of the catastrophic security holes caused by memory errors. While Rust offers a modern alternative, rewriting millions of lines of legacy code isn't always an option. Enter Fil-C: a bold new project that promises memory safety without forcing you to abandon your existing codebase.

Invisible Capabilities and the GC Magic

Fil-C isn't just another compiler flag; it's a fork of Clang/LLVM that fundamentally changes how memory is handled. The secret sauce is a combination of concurrent garbage collection and what Filip Pizlo calls "invisible capabilities."

Instead of relying on the programmer to manually track pointer bounds, Fil-C instruments LLVM IR to attach hidden metadata to every pointer. These capabilities track the valid range of memory for each pointer, and since they exist outside the C address space, they can't be tampered with by the user. When you try to access memory, Fil-C performs dynamic checks to ensure the operation is safe, catching violations before they become vulnerabilities.

Compatibility Without the Compromise

What makes Fil-C particularly interesting is its "fanatical" commitment to compatibility. Unlike other safety-focused languages that introduce a steep learning curve or a new syntax, Fil-C aims to be a drop-in replacement.

It handles the heavy lifting via a garbage collector that manages memory ranges for both the capabilities and the payloads. To keep things smooth, it uses a safe-point mechanism for synchronization and signal handling, ensuring that the GC doesn't clash with the thread's execution. It essentially transforms unsafe C operations into safe, checked operations at the IR level, bridging the gap between the flexibility of C and the security of managed languages.

A Bridge to the Future

While Fil-C is software-based, it shares a spiritual kinship with hardware-level solutions like CHERI. By implementing these safety checks in software today, Fil-C provides a path toward a world where C-like performance no longer requires a "danger" warning. If it can maintain its promise of total compatibility, we might finally stop choosing between speed and security.

Sources

Media