C Bounds Safety

superagents-lab/xcode27-skills/c-bounds-safety

作者 superagents-lab6f9ff8d5ad6000491cb0f483a776b7062e41cd97无许可证收录于 2026年10月9日更新于 2026年10月9日

Guide for the C -fbounds-safety language extension. Covers the language model, pointer annotations, adopting bounds-safety in existing C code, compiler build settings and modes, and runtime debugging of bounds violations.

AI 生成的概览

C 语言 -fbounds-safety 扩展指南:指针注解、在既有代码中的采用、构建设置与运行时调试。

功能
说明 -fbounds-safety 这一 C 语言扩展,它在语言层面强制边界安全,自动插入运行时边界检查并在编译期拒绝不安全的指针操作。文档介绍指针种类与注解,例如 counted_by、sized_by、ended_by、single、indexable、bidi_indexable、unsafe_indexable、null_terminated 和 terminated_by,以及 unsafe_forge_bidi_indexable、__ptrcheck_abi_assume_single 等辅助函数与宏。内容还涵盖在既有 C 项目中采用该扩展的流程、编译器构建设置与模式,以及边界违规的运行时调试。
适用场景
适用于阅读、审查、比较、调试或分析已采用或准备采用 -fbounds-safety 的 C 代码。也适用于处理边界注解、ptrcheck.h 及相关辅助宏,以及排查运行时的边界违规。主要面向既有 C 代码库中的采用与代码修改任务。
运行要求
不含脚本,仅为说明与参考文档;读取随附参考文件需要文件访问权限。无需额外软件包、凭据或网络访问。

How to Use This Skill

When helping with -fbounds-safety adoption or code changes, ask clarifying questions about the user's codebase and goals before suggesting changes. For complex tasks involving multiple files or non-trivial annotation decisions, use plan mode to propose an approach before implementing.

-fbounds-safety Language Extension

-fbounds-safety is a C language extension that prevents out-of-bounds memory access by enforcing bounds safety at the language level. It inserts automatic bounds checks at runtime, rejects unsafe pointer operations at compile time, and requires programmers to provide bounds annotations so the compiler can guarantee safety. Out-of-bounds accesses become deterministic traps instead of exploitable vulnerabilities.

Detailed Documentation

Required reading before adoption work

You MUST have fully read the following three documents (via the Read tool) at the start of an adoption task, and re-read them via the Read tool before any source-modifying step in the adoption workflow unless their content is verifiably fresh in your active context:

  • adoption-strategies.md [blocked] — the workflow for adopting -fbounds-safety in an existing C project (full and header-only modes).
  • language-overview.md [blocked] — the language reference for -fbounds-safety: pointer kinds, annotations, and the rules that govern them.
  • common-patterns-and-pitfalls.md [blocked] — recipes and anti-patterns encountered during real-world adoption.

Other references (read on demand)

For compiler flags, Xcode build settings, soft trap mode, and ptrcheck.h configuration, read build-settings.md [blocked].

For debugging bounds violations at runtime — trap behavior, LLDB commands, wide pointer inspection, watchpoints, crash log analysis, and soft trap debugging, read runtime-debugging.md [blocked].

来源与署名

来源:superagents-lab/xcode27-skills位于c-bounds-safety提交6f9ff8d

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架