知识卡片
回溯定位首个自有调用
用 RUST_BACKTRACE=1 重现 panic 后,从栈顶往下找到第一处自己的文件。其上通常是该调用触发的实现代码,其下是调用它的路径。先核对该行的操作和实参,比如向量下标是否超出长度。输出细节取决于调试符号和环境。
相关卡片 [[越界可崩溃或返回缺失]]
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 错误处理 Unrecoverable Errors with panic! · 查看原书依据
The note: line tells us that we can set the RUST_BACKTRACE environment variable to get a backtrace of exactly what happened to cause the error. A backtrace is a list of all the functions that have been called to get to this point.
参考来源
- 位置:《The Rust Programming Language(第2版)》第09章 错误处理(来源项目 a19c7933-4eda-4176-aebd-30fe7e1ad292,`extracted/The Rust Programming Language(第2版)/_epub-src/c09.xhtml`,块 0028)
- 结论依据:原文给出读取回溯的方向,并解释自有栈帧上下的调用关系。
- 原始内容:The note: line tells us that we can set the RUST_BACKTRACE environment variable to get a backtrace of exactly what happened to cause the error. A backtrace is a list of all the functions that have been called to get to this point.