C#/.NET analysis tool to find race conditions/deadlocks

守給你的承諾、 提交于 2019-11-27 03:49:24

You're probably looking for one of these:


NOTE: This answer is from 2010. As with all recommendations answers, recommendations tend to change over time. There may be other products out there now, CHESS which was a Microsoft Research Labs project may have evolved into a final product or been scrapped altogether. Please take this answer with a grain of salt and conduct new research into which products are suitable now.

John Gietzen

Jinx will do this at runtime (not statically) but it may be worth looking at.

Kent Boogaart

You might want to check out CHESS.

I have been experimenting on how to easily track those. I've been working to track some deadlocks, specially on scenarios where many different lock statements are used.

My goal is to detect deadlocks before they happen, e.g. if you have two resources, you know you have to always use them in the same order, otherwise a deadlock might occur.

lock (lockObj1) 
lock (lockObj2) 
{ 
    // some code
} 

... somewhere else in the app ...

lock (lockObj2) 
lock (lockObj1) // <- I expect some "possible deadlock" detection here 
{ 
    // some code
} 

In this case I'm using lockObj1 then lockObj2 in one place and using them in the opposite order in another place, this is something you will like to avoid in an application Of course, lock statements don't need to be used one after the other like in the example, your complex application might have several complex objects interacting with each other

I have uploaded the code with the test cases here https://github.com/glmnet/LockTracer

David d C e Freitas

See the answers here: What static analysis tools are available for C#?

Some static analysis tools can do deadlock detection.

Also, try FxCop from Microsoft.

Have you looked at Red-Gate Ants? I'm not sure if it will do everything you need but it is a good product to:

  • Identify performance bottlenecks within minutes
  • Optimize .NET application performance
  • Drill down to slow lines of code with line-level timings
  • Profile aspx, ASP.NET, C# code, and VB.NET applications
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!