Skip to content

maddress does not work in the new SOS since the release v8.0.547301 #5091

@oldzhu

Description

@oldzhu

Description

maddress does not work since the sos release v8.0.547301

0:000> .chain
...
Extension DLL chain:
sos: image 9,0,11,3101 @Commit: 5b61d34, API 2.0.0, built Thu Oct 31 13:41:29 2024
[path: C:\Users[username]\AppData\Local\DBG\ExtRepository\EG\cache3\Packages\SOS\9.0.11.3101\win-x64\sos.dll]

0:000> !sos maddress -summary
Enumerating and tagging the entire address space and caching the result...
Subsequent runs of this command should be faster.
!address did not produce a standard header.
This may mean symbols could not be resolved for ntdll.
Please run !address and make sure the output looks correct.

Configuration

Regression?

Yes maddress works fine in the previous sos and it looks like the regression by the below commit change.

Implement CLRMA interfaces on top of DAC APIs (#4667)

Other information

It is the below code added in dbgengservices.h caused the problem as the expression in _ASSERTE will only be compiled into the binary in debug build. That means there is no outputcallback will be set in the release version SOS, and maddress command works on the output of another address debugging command. No output callback set means maddress can not get the output of the address command so that it fails to work.

public:
    OutputCaptureHolder(IDebugClient* client, PEXECUTE_COMMAND_OUTPUT_CALLBACK callback) :
        m_ref(0),
        m_client(client),
        m_previous(nullptr),
        m_callback(callback)
    {
        _ASSERTE(SUCCEEDED(client->GetOutputCallbacks(&m_previous)));
        _ASSERTE(SUCCEEDED(client->SetOutputCallbacks(this)));
    }
    ~OutputCaptureHolder()
    {
        _ASSERTE(SUCCEEDED(m_client->SetOutputCallbacks(m_previous)));
        _ASSERTE(m_ref == 0);
    }

I verified the above by building both the latest debug and release SOS binary, maddress works fine in debug build and does not work in release build.

we also can see there is no call to m_client->SetOutputCallbacks in the release assembly code for the function ~OutputCaptureHolder and there is in debug assembly code for the same function.

Assembly code for release build ~OutputCaptureHolder

0:000> u 18000fa80
sos!OutputCaptureHolder::~OutputCaptureHolder [C:\Users\[username]\source\repos\diagnostics\src\SOS\Strike\dbgengservices.h @ 382]:
00000001`8000fa80 488d0559ed0800  lea     rax,[sos!OutputCaptureHolder::`vftable' (00000001`8009e7e0)]
00000001`8000fa87 488901          mov     qword ptr [rcx],rax
00000001`8000fa8a c3              ret
...

Assembly code for debug build ~OutputCaptureHolder

0:000> u 18001e150
sos!OutputCaptureHolder::~OutputCaptureHolder [C:\Users\[username]\source\repos\diagnostics\src\SOS\Strike\dbgengservices.h @ 382]:
00000001`8001e150 48894c2408      mov     qword ptr [rsp+8],rcx
00000001`8001e155 57              push    rdi
00000001`8001e156 4883ec40        sub     rsp,40h
00000001`8001e15a 488b442450      mov     rax,qword ptr [rsp+50h]
00000001`8001e15f 488d0d1a6a2200  lea     rcx,[sos!OutputCaptureHolder::`vftable' (00000001`80244b80)]
00000001`8001e166 488908          mov     qword ptr [rax],rcx
00000001`8001e169 488b442450      mov     rax,qword ptr [rsp+50h]
00000001`8001e16e 488b4010        mov     rax,qword ptr [rax+10h]
....

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingsos

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions