DynamoRIO / dynamorio

Dynamic Instrumentation Tool Platform
Other
2.64k stars 560 forks source link

tools/libdynamorio.so-gdb.py causes "RuntimeError: Cannot access memory at address 0x712fd867" #2100

Open thorstent opened 7 years ago

thorstent commented 7 years ago

I'm running DynamoRIO on a fresh Ubuntu 16.10 64bit VM in VirtualBox (Host is Windows).

I am using DynamoRIO 6.2 binary release. But the problem persists with the latest nightly 6.2.17144-0x12112de

My ~/.gdbinit file constists of these two lines:

add-auto-load-safe-path /home/ttarrach/Downloads/DynamoRIO-Linux-6.2.0-2/lib64/debug/libdynamorio.so.6.2-gdb.py
add-auto-load-safe-path /home/ttarrach/Downloads/DynamoRIO-Linux-6.2.17144-0x12112de/lib64/debug/libdynamorio.so.6.2-gdb.py

The minimal steps to reproduce this problem are:

  1. start GDB: ~/Downloads/DynamoRIO-Linux-6.2.0-2$ gdb --args bin64/drrun -debug -- ls
  2. type run into the GDB command prompt

Here is the complete output:

GNU gdb (Ubuntu 7.11.90.20161005-0ubuntu1) 7.11.90.20161005-git
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from bin64/drrun...Reading symbols from /home/ttarrach/Downloads/DynamoRIO-Linux-6.2.0-2/bin64/drrun.debug...done.
done.
(gdb) run
Starting program: /home/ttarrach/Downloads/DynamoRIO-Linux-6.2.0-2/bin64/drrun -debug -- ls
process 2728 is executing new program: /home/ttarrach/Downloads/DynamoRIO-Linux-6.2.0-2/lib64/debug/libdynamorio.so.6.2
Loading gdb scripts for debugging DynamoRIO...
Traceback (most recent call last):
  File "/home/ttarrach/Downloads/DynamoRIO-Linux-6.2.0-2/lib64/debug/libdynamorio.so.6.2-gdb.py", line 185, in <module>
    PrivloadBP()
  File "/home/ttarrach/Downloads/DynamoRIO-Linux-6.2.0-2/lib64/debug/libdynamorio.so.6.2-gdb.py", line 151, in __init__
    internal=not self.DEBUG)
RuntimeError: Cannot access memory at address 0x712fd867
<Starting application /bin/ls (2728)>
<Paste into GDB to debug DynamoRIO clients:
set confirm off
add-symbol-file '/home/ttarrach/Downloads/DynamoRIO-Linux-6.2.0-2/lib64/debug/libdynamorio.so' 0x000000007102d808
>
<Initial options = -no_dynamic_options -code_api -stack_size 56K -max_elide_jmp 0 -max_elide_call 0 -early_inject -emulate_brk -no_inline_ignored_syscalls -native_exec_default_list '' -no_native_exec_managed_code -no_indcall2direct >

I would expect the python script to run and not throw a memory exception. The same problems I observed in my Debian Jessie VM.

derekbruening commented 7 years ago

Looks like this is a duplicate of #1678 but since that one sat there we'll close it and have this remain.

Adding to the minimal steps:

Run the add-auto-load-safe-path command in gdb (or place into .gdbinit)

Contributions welcome.

derekbruening commented 3 years ago

Let's consider this issue covering reviving the libdynamorio.so-gdb.py script in general and having it auto-load DR symbols.

derekbruening commented 1 year ago

For the particular wrong address issue it may have the base library address wrong somehow; xref https://github.com/DynamoRIO/dynamorio/blob/master/tools/gdb-scripts/gdb-drsymload.py referenced at https://dynamorio.org/page_debugging.html#autotoc_md143