valgrind的DRD和Helgrind
valgrind的DRD和Helgrind
处理一个bug时,使用strace 发现线程死锁。
但是发生死锁的位置上下文怎样快速知道呢?
使用gdb 调试 打出调用栈,只能知道运行到此处发生死锁。但是是哪里开始出现死锁呢??
google搜索发现valgrind 的Helgrind
可以解决
这个时候Helgrind
就该出场了:valgrind --tool=helgrind ./nobady
Helgrind is a Valgrind tool for detecting synchronisation errors in C/C++ programs that use the POSIX threading primitives. The main abstractions in POSIX are: a set of threads sharing a common address space, thread creation, thread joining, thread exit, mutexes (locks), condition variables and barriers. Helgrind detects three types of errors: (1) misuses of the POSIX API, (2) potential deadlocks arising from lock ordering problems, and (3) data races.
http://epic-beta.kavli.tudelft.nl/share/doc/valgrind-3.8.1/html/hg-manual.html
http://www.it.uc3m.es/pbasanta/asng/course_notes/helgrind_tool_en.html
也就是说 Helgrind 可以解决 死锁、资源访问不安全等问题
所以问题也就很快解决了
gdb调试技巧:
disassemble 命令
参考:blog
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南