惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Engineering at Meta
Engineering at Meta
D
Docker
IT之家
IT之家
博客园_首页
罗磊的独立博客
V
V2EX
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
美团技术团队
Y
Y Combinator Blog
博客园 - 聂微东
量子位
阮一峰的网络日志
阮一峰的网络日志
GbyAI
GbyAI
Microsoft Security Blog
Microsoft Security Blog
博客园 - Franky
Martin Fowler
Martin Fowler
Jina AI
Jina AI
大猫的无限游戏
大猫的无限游戏
C
Check Point Blog
月光博客
月光博客
G
Google Developers Blog
B
Blog
T
The Blog of Author Tim Ferriss
爱范儿
爱范儿

Last Blog

CMU 15-213 Attack Lab GAMES101 [1] Affine Transformation & Projection CMU 15-213 Bomblab CMU 15-213 [1] Scribe.cx 2 - 对话与持久化存储 关于 X11 与 Wayland 的剪贴板同步问题 关于 X11 与 Wayland 的剪贴板同步问题 Scribe.cx 1 - 跨浏览器的插件侧板控制 Page Assist 2025 年终总结 2025 年终总结 Linuxqq 粘贴板同步问题 关于所谓“配置工程师” 记一次小端序内存的实际体现 CS110L L3 - Memory Safety in Rust CS110L L1 - Safety in System Programming 在 Neovim(v0.10+) 上使用 arduino-language-server PA3 - Batch Processing System 2024 年终总结 Arcaea 曲名匹配器 Arcaea 曲名匹配器 PA W9 - Linking & Loading Hyprland 二周目 Hyprland 二周目 PA2 Part 2 - Emulated Hardware Device PA W8 - IO Devices Learn C the Hard Way PA2 Part 1 - Instruction Set Implementation & KLIB Learning Makefile with PA 阅读 MQTTX 项目:Protobuf Test Case
CS110L L2 - Program Analysis
Last · 2025-05-01 · via Last Blog

Warning

If someone is reading this blog, please be aware that the writer did not consider the experience of the other readers.
After all, the most important part is about writing things down for better memorization.

Valgrind

  • Valgrind is an instrumentation framework for building dynamic analysis tools. There are Valgrind tools that can automatically detect many memory management and threading bugs, and profile your programs in detail.

  • The tool does it’s job by modifying some of the assembly code which is assosiated to memory operation, like call malloc or load/store, when executing the code.

  • It is doing what we call ‘dynamic analysis’, which is run the program and watch what it does.

  • Though it is able to detect heap-based buffer overflows, valgrind cannot detect stack-based buffer overflows, as it does not know the source code of the program and has no idea about the stack layout.

LLVM Sanitizers

  • Instead of instrumenting binary file like Valgrind does, it instruments the source code.

  • There’re several kinds of sanitizers, including memory sanitizer, leak sanitizer, undefined behavior sanitizer and thread sanitizer.

Fundamental Limitation of Dynamic Analysis

  • Dynamic analysis can only report bad behavior that actually happened.

  • The program might crash due to some specific input from the user which is probably not going to show up during the test/dynamic analysis.

  • This leads to the fact that, we just can’t find lots of the issues before it happens. There’re just too much possible issues.

Fuzzing Testing

  • A very simple but extremely effective way to find bugs.

  • AFL & libfuzzer

  • Still can not provide any guarantees that a program is bug-free.

Static Analysis

  • Static analyzers could be helpful when finding bugs in the code by doing data-flow analysis. It can detect some edge cases that dynamic analysis might never be able to run into.

  • However, static analyzers can report a lot of false positives, which means that reporting bugs that could only be triggerred theoratically and impossible in real world.

  • Also, tracing every possible control flow could be a very cpu-consuming job.

  • Plus a whole bunch of potential problems. There’re just too many possible issues that exceeds the limit of code analysis.