DynamoRIO / DynamoRIO/drmemory

Uninit reads below SetupDiGetClassDevsW

Open
#503 10 comments 0 reactions 0 assignees View on GitHub
Bug-FalsePositive Migrated OpSys-Windows Priority-Medium
Dominant language
C
Stars
2.7k
Forks
290
PR merge metrics
No merged PRs in 30d

Description

_From [timurrrr@google.com](https://code.google.com/u/timurrrr@google.com/) on July 21, 2011 06:10:44_

Repro taken from issue #499 :
#

#include
#include

#include

#pragma comment(lib, "ole32.lib")
#pragma comment(lib, "strmiids.lib")

class ScopedCOMInitializer {
public:
ScopedCOMInitializer() : hr_(CoInitialize(NULL)) { }

```
ScopedCOMInitializer::~ScopedCOMInitializer() {
if (SUCCEEDED(hr_))
CoUninitialize();
}
```

private:
HRESULT hr_;
};

int main() {
ScopedCOMInitializer sci;

```
ICreateDevEnum *dev_enum;
HRESULT hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC,
IID_ICreateDevEnum, (LPVOID*)&dev_enum);
if (!SUCCEEDED(hr)) {
printf("FAIL\n");
return 1;
}

IEnumMoniker *moniker;
hr = dev_enum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &moniker, 0);
if (SUCCEEDED(hr)) {
printf("PASS\n");
} else {
printf("FAIL\n");
return 1;
}
dev_enum->Release();

return 0;
```

}
#

[XP 32-bit with symbols]

Error `#1`: UNINITIALIZED READ: reading register eax
@0:00:05.626 in thread 4280
0x7792b4c6 SETUPAPI.dll!SetupDiGetClassDevsExW
0x7792b604 SETUPAPI.dll!SetupDiGetClassDevsW
0x75f49bf7 DEVENUM.DLL!CEnumInterfaceClass::GetDevicePath
0x75f47588 DEVENUM.DLL!CCreateSwEnum::CreateOnePnpMoniker
0x75f4769d DEVENUM.DLL!CCreateSwEnum::CreatePnpMonikers
0x75f4837d DEVENUM.DLL!CCreateSwEnum::CreateClassEnumerator
0x75f442c4 DEVENUM.DLL!CClassManagerBase::CreateClassEnumerator
0x75f48344 DEVENUM.DLL!CCreateSwEnum::CreateClassEnumerator
0x75f46e0e DEVENUM.DLL!CCreateSwEnum::CreateClassEnumerator
0x00401099 test.exe!main
test.cpp:34

...

Error `#3`: UNINITIALIZED READ: reading 0x00185d82-0x00185d84 2 byte(s)
@0:00:05.673 in thread 4280
0x10038293 drmemorylib.dll!replace_wcslen
drmemory\replace.c:323
0x7792cfc7 SETUPAPI.dll!OpenDeviceInterfaceSubKey
0x7792d19c SETUPAPI.dll!pSetupGetDevInstNameAndStatusForInterfaceDevice
0x7792d481 SETUPAPI.dll!SetupDiGetClassDevsExW
0x7792b604 SETUPAPI.dll!SetupDiGetClassDevsW

[XP 32-bits w/o symbols]

Error `#2`: UNINITIALIZED READ: reading register eax
@0:00:04.035 in thread 5720
0x7792b4c6 SETUPAPI.dll!SetupDiGetClassDevsExW
0x7792b604 SETUPAPI.dll!SetupDiGetClassDevsW
0x75f49bf7 DEVENUM.DLL!DllUnregisterServer
0x75f47588 DEVENUM.DLL!DllUnregisterServer
0x75f4769d DEVENUM.DLL!DllUnregisterServer
0x75f4837d DEVENUM.DLL!DllUnregisterServer
0x75f442c4 DEVENUM.DLL!?
0x75f48344 DEVENUM.DLL!DllUnregisterServer
0x75f46e0e DEVENUM.DLL!DllUnregisterServer
0x00401099 test.exe!main
test.cpp:34

...

Error `#4`: UNINITIALIZED READ: reading 0x00185d82-0x00185d84 2 byte(s)
@0:00:04.067 in thread 5720
0x10038293 drmemorylib.dll!replace_wcslen
drmemory\replace.c:323
0x7792cfc7 SETUPAPI.dll!SetupDiEnumDeviceInterfaces
0x7792d19c SETUPAPI.dll!SetupDiEnumDeviceInterfaces
0x7792d481 SETUPAPI.dll!SetupDiEnumDeviceInterfaces
0x7792b604 SETUPAPI.dll!SetupDiGetClassDevsW

#

Looks like some NtUser syscall doesn't initialize some of its OUT fields?

_Original issue: http://code.google.com/p/drmemory/issues/detail?id=503_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.