How to find a content of the default TaskScheduler in a dump of a .NET application?
Asked Answered
H

1

6

I am trying to find a content of the default TaskScheduler in a dump of a .NET application. How I can do that?

An application was hung.

application was hung

I need to make sure that the default scheduler contains a delayed task with a certain delegate.

Hemialgia answered 15/3, 2016 at 13:37 Comment(3)
@LievenKeersmaekers: I think he's talking about the TaskScheduler classEngdahl
Yes, I am talking about the TaskScheduler class. Specifically about the TaskScheduler.Default PropertyHemialgia
Is it a regular .dmp? Try opening it in Visual Studio. Given sufficient symbols, the debugger should be able to display an overview of tasks (Debug -> Windows -> Tasks). If it's a partial dump or you have no symbols, this will not work, but it's worth a try.Research
E
1

First, find the method table of the TaskScheduler

0:025> .loadby sos clr
0:025> .symfix c:\debug\symbols
0:025> !name2ee mscorlib.dll System.Threading.Tasks.TaskScheduler
Module:      000007feeea11000
Assembly:    mscorlib.dll
Token:       000000000200052e
MethodTable: 000007feef0a8ab0
EEClass:     000007feeebde1a8
Name:        System.Threading.Tasks.TaskScheduler

Then, dump the heap to find some objects of that type. Note that I'm using String here, since I don't have an application with a TaskScheduler available.

0:025> !dumpheap -mt <MethodTable>

Now that you have some objects, just dump one of them.

0:025> !do 00000000126ed548 
Name:        System.String
MethodTable: 000007feef0bda88
EEClass:     000007feeea16a08
Size:        34(0x22) bytes
File:        C:\Windows\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll
String:      100%
Fields:
              MT    Field   Offset                 Type VT     Attr            Value Name
000007feef0c03d0  4000243        8         System.Int32  1 instance                4 m_stringLength
000007feef0bec38  4000244        c          System.Char  1 instance               31 m_firstChar
000007feef0bda88  4000248       80        System.String  0   shared           static Empty

Notice the shared (static) property Empty for the String. You should get something similar in TaskScheduler for the static property Default.

As you can see, you can see nothing. That's why you need the SOSEX extension and do a !mdt System.Threading.Tasks.TaskScheduler.

0:025> !mdt System.String
System.String
[...]
    [s]Empty: string
        AppDomain 'Test.exe' (0000000001d73470): 0000000011fc1420[System.String] STRVAL=
Engdahl answered 15/3, 2016 at 15:2 Comment(2)
This answer is unlikely to yield any results relevant to the question. The tasks scheduled by TaskScheduler.Default aren't found in any instance properties of the class in most implementations (specifically not ThreadPoolTaskScheduler). An actual answer is a lot more involved.Research
@JeroenMostert: as mentioned in the comments, that's what he wanted. If it doesn't solve the problem, that's a different story. If you know a better answer, I'd be glad to hear about it. Feel free to downvote.Engdahl

© 2022 - 2024 — McMap. All rights reserved.