DynamoRIO / DynamoRIO/drmemory

Documentation is incomplete for preparing Visual Studio C++ code for Dr. Memory (missing /MTd)

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

Description

**Describe the bug**
[Documentation page "Preparing your application", section "Windows Visual Studio"](https://dynamorio.org/drmemory_docs/page_prep.html#sec_prep_windows) is missing the fact that, for C++ applications, programmers must set "runtime library" (in "Configuration Properties | C/C++ | Code Generation") to "/MTd" (and not "/MDd")

This has been observed with VisualStudio 2017 and 2019.

**To Reproduce**
1. Create a "Console application" solution
2. Copy/paste the following code in ConsoleAPplication.cpp

#include iostream>

#include string>
int main()
{
char* t = static_cast(malloc(10));
std::string *s = new std::string();
std::cout << "Hello World!\n";
}

3. Generate the solution. By default, it is generated with "runtime library" (in "Configuration Properties | C/C++ | Code Generation") set to "/MDd"
4. Menu Tools > DEr. Memory gives the following result
Dr. Memory version 2.3.0

Running "C:\Users\simatic\Source\Repos\ConsoleApplication4\x64\Debug\ConsoleApplication4.exe"
Hello World!

Error #1: LEAK 10 bytes
replace_malloc
d:\drmemory_package\common\alloc_replace.c(2577):
main
C:\Users\simatic\Source\Repos\ConsoleApplication4\ConsoleApplication4\ConsoleApplication4.cpp(5):

ERRORS FOUND:
0 unique, 0 total unaddressable access(es)
0 unique, 0 total uninitialized access(es)
0 unique, 0 total invalid heap argument(s)
0 unique, 0 total GDI usage error(s)
0 unique, 0 total handle leak(s)
0 unique, 0 total warning(s)
1 unique, 1 total, 10 byte(s) of leak(s)
0 unique, 0 total, 0 byte(s) of possible leak(s)

Only the leak related to the malloc at line is seen is seen. The leak related to the new at line 6 is not seen.

**Expected behavior**
If we want Dr. Memory to see the leak related to the new at line 6, we must set "runtime library" (in "Configuration Properties | C/C++ | Code Generation") to "/MTd" (and not "/MDd")

Thus, I propose to mention it in Dr. Memory documentation.

**Versions**
- What version of Dr. Memory are you using? 2.3.0
- Does the latest build from
https://github.com/DynamoRIO/drmemory/wiki/Latest-Build solve the problem? Not applicable
- What operating system version are you running on? ("Windows 10" is *not* sufficient: give the release number.) Windows 10 Enterpirse version 1703
- Is your application 32-bit or 64-bit? 32-bit and 64-bit applications experience the problem

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.