DynamoRIO / DynamoRIO/drmemory

False positive on Win API WS2_32 calls

Open
#2,477 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
2.7k
Forks
290
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
Although I found here some past issues telling that these reports where "false positives" and fixed around 2015, it seems that simple programs using windows sockets and file API still reports "UNINITIALIZED READ"

**To Reproduce**
Create a new cmake project in MSVC 2022 17.4.3, using Win10 SDK and edit the cmakelists.txt to link on ws2_32 library

Compile the following program
```c++
#define WIN32_LEAN_AND_MEAN

#include

int main()
{
WSAData wsaData;
WSAStartup(MAKEWORD(2, 2), &wsaData);
WSACleanup();
return 0;
}
```

Output is :

```
Error #1: UNINITIALIZED READ: reading register eax
# 0 WS2_32.dll!WSALookupServiceNextW +0x23f1 (0x00007ff805ceded1 )
# 1 WS2_32.dll!WSALookupServiceNextW +0x2ffd (0x00007ff805ceeade )
# 2 WS2_32.dll!WSAStartup +0x33c (0x00007ff805ceee4d )
# 3 main [C:\Users\...\source\repos\WinSocketsCalls\WinSocketsCalls.cpp:17]
Note: @0:00:00.262 in thread 26452
Note: instruction: cmp %eax %r12d

Error #2: UNINITIALIZED READ: reading register eflags
# 0 WS2_32.dll!WSALookupServiceNextW +0x240f (0x00007ff805cedeef )
# 1 WS2_32.dll!WSALookupServiceNextW +0x2ffd (0x00007ff805ceeade )
# 2 WS2_32.dll!WSAStartup +0x33c (0x00007ff805ceee4d )
# 3 main [C:\Users\...\source\repos\WinSocketsCalls\WinSocketsCalls.cpp:17]
Note: @0:00:00.263 in thread 26452
Note: instruction: cmovo %r13 -> %rax

Error #3: UNINITIALIZED READ: reading 0x000000ef7b5af940-0x000000ef7b5af944 4 byte(s) within 0x000000ef7b5af940-0x000000ef7b5af948
# 0 replace_memset [D:\a\drmemory\drmemory\drmemory\replace.c:194]
# 1 WS2_32.dll!WSALookupServiceNextW +0x2448 (0x00007ff805cedf29 )
# 2 WS2_32.dll!WSALookupServiceNextW +0x2ffd (0x00007ff805ceeade )
# 3 WS2_32.dll!WSAStartup +0x33c (0x00007ff805ceee4d )
# 4 main [C:\Users\...\source\repos\WinSocketsCalls\WinSocketsCalls.cpp:17]
Note: @0:00:00.277 in thread 26452
Note: instruction: cmp 0x30(%rsp) $0x0000000000000003
```

**Expected behavior**
This program should be valid and no errors should be reported

**Versions**
- What version of Dr. Memory are you using?
Dr. Memory version 2.5.19327 build 0 built on Dec 1 2022 15:38:39

- What operating system version are you running on? ("Windows 10" is *not* sufficient: give the release number.)
Windows version: WinVer=105;Rel=2009;Build=19042;Edition=Enterprise

- Is your application 32-bit or 64-bit?
64 bits

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.