• Category: Languages
  • Status: developing
  • Sources: Fil-C documentation, discussion
  • Summary: Fil-C, the memory-safe C and C++ compiler, published documentation for memory-safe implementations of the setjmp/longjmp and ucontext (getcontext, setcontext, makecontext, swapcontext) context-switching APIs. The setjmp path stores an opaque jump buffer unreachable from user code, requires direct setjmp calls so the compiler cannot optimize away the safety guarantees, validates that each longjmp targets a live descendant stack frame, and preserves garbage-collection roots; misuse that would otherwise produce a torn machine state triggers a runtime panic rather than memory corruption. The ucontext path uses opaque fiber-context objects with internally allocated stacks, enforces thread affinity so a context cannot migrate between threads, and integrates with the collector through fiber tracking. The documentation states ucontext support is new since release 0.680, requires building from source, and is not yet thoroughly tested, while setjmp/longjmp is described as more solid.
  • Why it matters: Context-switching APIs are a recurring memory-safety escape hatch in C, and constraining them to fail closed extends Fil-C's guarantees to coroutine and fiber code that previously relied on raw register and stack manipulation.

Send feedback on this story