Analyzing output of !threadpool and !threads in windbg

允我心安 提交于 2019-12-03 02:15:35

1)How can I determine what the source of those 27 timers are?

Try to find instances of TimerCallback (for Threading.Timer):

!dumpheap -type TimerCallback

Then dump the callback properties (where callback address is the "Address" from the dumpheap output):

!do <callback address>

Then dump the Value address of the _target property:

!do <_target address>

That should spit out the object that holds a reference to the TimerCallback, which should lead you to where the timer was created.

I recommend checking out Tess Ferrandez's debugging labs, if you haven't already.

2)What does 13 dead threads mean?

My understanding is that a dead thread refers to a C++ thread which no longer has an active OS thread, but still has references and thus cannot be destroyed (C++ threads use ref counting).

A C# thread holds a reference to a C++ thread, and if your managed code keeps a reference to a C# thread, then that could be your problem.

This post on Yun Jin's blog might be of some interest to you.

3)One of my threads is marked as having a lock. If i switch to that thread and run !clrstack, i see the following - is it related to my timers?

That looks like a (System.Threading) timer thread waiting for its interval to elapse.

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