Should I use Helgrind or DRD for thread error detection?

别说谁变了你拦得住时间么 提交于 2019-12-04 15:13:11

问题


Looks like Valgrind has two tools that both do thread error detection: Helgrind and DRD. These tools are substantially similar.

My primary question is: when should I use one instead of the other to check my multi-threaded code?

More broadly, why are there two tools? I assume they aren't entirely redundant. What are the important differences? Should I generally plan on running my code through both tools?


回答1:


While Helgrind can detect locking order violations, for most programs DRD needs less memory to perform its analysis. Also, DRD has support for detached threads. There are more subtle differences too - compare the respective manuals if you want to know more. See also http://valgrind.org/docs/manual/hg-manual.html and http://valgrind.org/docs/manual/drd-manual.html.




回答2:


If you're using any POSIX synchronization primitives besides mutexes (e.g., semaphores, barriers, condition variables, etc.), DRD is worth a run -- it can identify some subtle misuses that Helgrind doesn't detect.

However, DRD seems to be much more resource intensive than Helgrind (in my runs using 3.14.0 there seems to be a tremendous amount of CPU overhead).




回答3:


when should I use one instead of the other to check my multi-threaded code?

Depends on what you want to check that code for.

To check for data races, you might want to use ThreadSanitizer.
Comparison with DRD and others.




回答4:


One other point to consider: as of valgrind version 3.6.0, DRD supports pthread spinlocks, but helgrind doesn't. I haven't tried 3.7.0, but the release notes lead me to believe that this hasn't changed.



来源:https://stackoverflow.com/questions/8157669/should-i-use-helgrind-or-drd-for-thread-error-detection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!