Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dr. Memory fails on DR assertion when an empty or trivial .cpp file is added to the build #544

Open
derekbruening opened this issue Nov 28, 2014 · 10 comments

Comments

@derekbruening
Copy link
Contributor

From [email protected] on August 30, 2011 05:40:45

Initially filed as https://code.google.com/p/drmemory/issues/detail?id=440 but turns out it's more of a DR problem.

In short, Dr. Memory is a C-only client.
When I try to add a simple C++ file it crashes on start with different symptoms in different configurations.
I'm seeing the following results as of r958 (DrM revision 482 )

Patch 1:

$ git diff trunk
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 151386b..572f288 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -632,6 +632,7 @@ else (TOOL_DR_HEAPSTAT)
drmemory/alloc_drmem.c
drmemory/syscall.c
drmemory/report.c

  • drmemory/empty.cpp
    drmemory/replace.c
    drmemory/leak.c
    drmemory/perturb.c
    diff --git a/drmemory/empty.cpp b/drmemory/empty.cpp
    new file mode 100755
    index 0000000..5f7c77d
    --- /dev/null
    +++ b/drmemory/empty.cpp
    @@ -0,0 +1 @@
    +//

$ mkdir debug && cd debug
$ cmake -DCMAKE_BUILD_TYPE=Debug .. && cmake --build .
$ ./bin/drmemory.exe -- ./tests/hello.exe
DynamoRIO usage error : failure to process imports of client library (dynamorio\core\loader_shared.c, line 120)

the Release build fails to start with a few "WARNING: unable to locate results file since can't open .../resfile" lines printed to stderr.

Patch 2: [attached] // also replaces msvcrt linking with libcmt[d] and adds some simple C++ code to run.

A larger patch (attached) fails in the Debug build (both DR and DrM are Debug):
...
Usage error: privately-loaded library executed by app:
please report this transparency violation (dynamorio\core\vmareas.c, line 7261)
...
CURIOSITY : name[1] == ':' && (name[2] == '/' || name[2] == '') && "create file invalid name"
in file dynamorio\core\win32\os.c line 4479
// name = "USER32.DLL" while the drive letter is expected?

If I use Release DR (regardless of the DrM build) it works fine with the second patch.


Are there any known C++ DR clients except for stl_test?

Attachment: empty_cpp_drm.patch

Original issue: http://code.google.com/p/dynamorio/issues/detail?id=544

@derekbruening
Copy link
Contributor Author

From [email protected] on August 30, 2011 07:43:40

the "Patch 2" errore are issue #486 and issue #487 , right?
does it work on Linux?

@derekbruening
Copy link
Contributor Author

From [email protected] on August 30, 2011 08:38:34

the "Patch 2" errore are issue #486 and issue #487 , right?
Right. Sorry for filing a new issue on that - I was searching for "Open and reported by me". Didn't realize you've filed them for me :)

does it work on Linux?
Good question! Testing...

@derekbruening
Copy link
Contributor Author

From [email protected] on August 30, 2011 08:59:38

does it work on Linux?
Nope, on both Debug and Release it crashes like this when Patch 1 is applied:
:::Dr.Memory::: Dr. Memory version 1.4.483
:::Dr.Memory::: options are "-logdir debug/logs "
:::Dr.Memory::: log dir is debug/logs/DrMemory-hello.23585.000

:::Dr.Memory::: :::Dr.Memory::: ERRORS FOUND: :::Dr.Memory::: 0 unique, 0 total warning(s) ...

Works OK w/o the patch

Cc: [email protected]

@derekbruening
Copy link
Contributor Author

From [email protected] on August 30, 2011 09:37:26

Patch 2 crashes with
:::Dr.Memory::: Dr. Memory version 1.4.483
:::Dr.Memory::: options are "-logdir release_p2/logs "
:::Dr.Memory::: log dir is release_p2/logs/DrMemory-hello.32669.000
:::Dr.Memory::: BOO = FFFFFBFA

[both Debug and Release]

which looks exactly the same way as on Windows

@derekbruening
Copy link
Contributor Author

From [email protected] on September 01, 2011 08:38:15

Are there any known C++ DR clients except for stl_test?

We would love to have more C++ samples and tests if you're interested in contributing

@derekbruening
Copy link
Contributor Author

From [email protected] on September 01, 2011 08:46:33

Are there any known C++ DR clients except for stl_test?
We would love to have more C++ samples and tests
if you're interested in contributing
I am, that's why I've started Dr.ASAN
and that's why I'm so stubborn trying to add C++ to Dr. Memory :)

But the question was different: are there any clients that do use C++ but not affected by this issue?

@derekbruening
Copy link
Contributor Author

From [email protected] on September 01, 2011 08:48:16

We would love to have more C++ samples and tests
if you're interested in contributing
bah, misread your sentence.
OK, will try to minimize DrM to something reasonably small. Not sure how hard it'd be though.
Maybe will try to play with a standalone mixed C/C++ client

@derekbruening
Copy link
Contributor Author

From [email protected] on September 01, 2011 08:51:09

are there any clients that do use C++ but not affected by this issue?

not that I'm aware of

@derekbruening
Copy link
Contributor Author

From [email protected] on September 23, 2011 10:42:13

I believe patch 2, on Windows, is nothing more than issue #487 , issue #486 , and issue #560 patch 1, on Windows, is failure to find SxS dir dynamically (have to read manifest file): issue #233 privload_process_imports: drmemorylib.dll imports from MSVCR80.dll
privload_locate_and_load: looking for E:\derek\drmemory\git\build_drmemory/bin/debug/MSVCR80.dll
privload_locate_and_load: looking for e:\derek\dr\git\exports\ext\lib32\debug/MSVCR80.dll
privload_locate_and_load: looking for C:\WINDOWS/system32/MSVCR80.dll
privload_locate_and_load: looking for C:\WINDOWS/MSVCR80.dll
privload_process_imports: unable to load import lib MSVCR80.dll
privload_load_finalize: failed to process imports drmemorylib.dll

leaving open for investigating whether the Linux failure is new or a dup of existing issues

Status:
Owner: [email protected]
Cc: [email protected]
Labels: -OpSys-Windows OpSys-Linux

@derekbruening
Copy link
Contributor Author

From [email protected] on September 23, 2011 12:03:20

for patch 1, solved by adding libcpmt and libcmt explicitly to C++ clients in
DynamoRIOConfig.cmake ( issue #233 , forthcoming). since ntdll needs to be linked after, had to move the link line in drmem, and remove msvcrt:

% git diff
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 151386b..906ec5f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -632,6 +632,7 @@ else (TOOL_DR_HEAPSTAT)
drmemory/alloc_drmem.c
drmemory/syscall.c
drmemory/report.c

  • drmemory/empty.cpp
    drmemory/replace.c
    drmemory/leak.c
    drmemory/perturb.c
    @@ -669,10 +670,6 @@ set_target_properties(${client_target} PROPERTIES
    set_property(TARGET ${client_target} PROPERTY COMPILE_DEFINITIONS ${DEFINES_NO_D})

if (WIN32)

  • we statically link with msvcrt.lib for vc /O2's use of __aulldvrm

  • this does NOT add any dynamic dependence on libc

  • target_link_libraries(${client_target} ntdll msvcrt)

our addr2line for Windows

add_executable(winsyms tools/winsyms.c)
target_link_libraries(winsyms dbghelp)
@@ -742,6 +739,12 @@ use_DynamoRIO_extension(${client_target} drcontainers)
set_target_properties(${client_target} PROPERTIES

dlls are put in runtime dir but we want lib dir

RUNTIME_OUTPUT_DIRECTORY${location_suffix} "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
+if (WIN32)

  • we statically link with msvcrt.lib for vc /O2's use of __aulldvrm

  • this does NOT add any dynamic dependence on libc

+# target_link_libraries(${client_target} ntdll msvcrt)

  • target_link_libraries(${client_target} ntdll)
    +endif (WIN32)
    if (DEBUG_BUILD AND WIN32)

    annoying to have ASLR and not on module list

get_target_property(cur_flags ${client_target} LINK_FLAGS)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant