知识卡片
跨语言展开遵循ABI边界
跨语言panic需按ABI明确处理。Rust panic遇不允许展开的C边界通常安全终止进程,并非一概未定义行为;适当C-unwind ABI可允许特定展开,panic=abort仍直接终止。若要转为错误结果,应在边界内捕获可展开panic并检查状态;外国异常与Rust捕获机制不能任意混用。
纠正依据:Rustonomicon FFI与展开,2026-10-27读取相关段落。
这张卡片看不懂?
这张卡片的反馈已满 10 条,暂时无法继续提交。
已有反馈 · 0 / 10 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Chapter 6. Beyond Standard Rust Invoking Rust from C · 查看原书依据
prevent panic!s from crossing the FFI boundary, as this always results in undefined behavior—undefined but bad!8
参考来源
- 位置:《Effective Rust 35 Specific Ways to Improve Your Rust Code (David Drysdale)》第6章《Invoking Rust from C》(spine10;extracted/Effective Rust 35 Specific Ways to Improve Your Rust Code (David Drysdale)/_epub-src/OEBPS/ch06.html;u180-ch06-017)。
- 结论依据:原文在“prevent panic!s”附近的定义、例子或代码支撑本卡核心说明:跨语言panic需按ABI明确处理。边界按已读前提解释;示例未执行。
- 原始内容:prevent panic!s from crossing the FFI boundary, as this always results in undefined behavior—undefined but bad!8