DynamoRIO / DynamoRIO/drmemory

350+ false uninit reports when using DBGHELP.LIB functions like SymFromAddr

Open
#52 0 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 September 15, 2010 09:36:28_

As of r46 ,
===test.cpp===
#define _WIN32_WINNT 0x0600
#include

#include

#pragma comment(lib, "dbghelp.lib")
#pragma comment(lib, "kernel32.lib")

#include

BOOL symtable_initialized = SymInitialize(GetCurrentProcess(), NULL, TRUE);

int main() {
void *stack[20];
int nstack =
::CaptureStackBackTrace(0, sizeof(stack)/sizeof(stack[0]),
stack, NULL);
// From http://msdn.microsoft.com/en-us/library/ms680578(VS.85).aspx for (int i = 0; i < nstack; i++) {
DWORD frame = (DWORD)stack[i];
ULONG64 buffer[(sizeof(SYMBOL_INFO) +
MAX_SYM_NAME \* sizeof(TCHAR) +
sizeof(ULONG64) - 1) / sizeof(ULONG64)];
PSYMBOL_INFO pSymbol = (PSYMBOL_INFO) buffer;

```
pSymbol->SizeOfStruct = sizeof(SYMBOL_INFO);
pSymbol->MaxNameLen = MAX_SYM_NAME - 1;

if (!SymFromAddr(GetCurrentProcess(), frame,
NULL, pSymbol)) {
fprintf(stderr, "[0x%X]\n", frame);
continue;
}

IMAGEHLP_LINE64 line;
SymSetOptions(SYMOPT_LOAD_LINES);
line.SizeOfStruct = sizeof(IMAGEHLP_LINE64);
DWORD line_disp = 0;

if (SymGetLineFromAddr64(GetCurrentProcess(), frame, &line_disp, &line))
fprintf(stderr, "[0x%X] \<%s:%i>\n", frame, pSymbol->Name, line.LineNumber);
else
fprintf(stderr, "[0x%X] \<%s>\n", frame, pSymbol->Name);
```

}
return 0;
}
#

# please note you must have the proper Platform SDK in your INCLUDE
cl /MTd /nologo /Zi test.cpp && drmemory -- test.exe
-> 350+ uninit reports

With the following suppressions:
===suppress.txt===
UNINITIALIZED READ
...
DBGHELP.dll!SymInitialize

UNINITIALIZED READ
...
DBGHELP.dll!SymEnumSourceFiles

UNINITIALIZED READ
...
msvcrt.dll!_RTDynamicCast
# newline due to issue #41 ==================
-> has only 2 reports suppressed in issue #14

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

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.