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

posted @   codestacklinuxer  阅读(167)  评论(0编辑  收藏  举报
编辑推荐:
· 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代理技术深度解析与实战指南
点击右上角即可分享
微信分享提示