DynamoRIO / dynamorio

Dynamic Instrumentation Tool Platform
Other
2.63k stars 557 forks source link

SIGSEGV with on Risc-v target #6689

Closed akhileshkumar80 closed 7 months ago

akhileshkumar80 commented 7 months ago

Hello

I am using dynamorio release 10.0.0 since for risc-v since pre-compiled binaries are not available I compiled the source with open source risc-v toolchain with supported version (9.4.0).

But when I run any application with this tool always getting sig11.

root@starfive:~/build_riscv64_backup# bin64/drrun -t drcov --dump_text -- /bin/ls root@starfive:~/build_riscv64_backup# bin64/drrun ls <Application /bin/ls (776). Cannot correctly handle received signal 11 in thread 776: default action in native thread.> root@starfive:~/build_riscv64_backup#

It seems that seg fault from instr_encode_arch function with copy_pc argument .

Could you please let me know is this issue related with my setup or for risc-v DynamoRIO is underdevelopment not test testable currently ?

BT :-

For bug reporting instructions, please see: https://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 /root/build_riscv64_backup/bin64/drrun.debug... (gdb) b main Breakpoint 1 at 0x53a0: file /data2/phase2/benchmarking/temp/dynamorio/tools/drdeploy.c, line 1149. (gdb) r ls Starting program: /root/build_riscv64_backup/bin64/drrun ls [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/riscv64-linux-gnu/libthread_db.so.1".

Breakpoint 1, main (argc=2, targv=0x3ffffffad8) at /data2/phase2/benchmarking/temp/dynamorio/tools/drdeploy.c:1149 1149 /data2/phase2/benchmarking/temp/dynamorio/tools/drdeploy.c: No such file or directory. (gdb) shell cat /proc/m meminfo misc modules mounts mtd
(gdb) shell ps PID TTY TIME CMD 451 ttyS0 00:00:00 login 594 ttyS0 00:00:01 bash 785 ttyS0 00:00:01 gdb 791 ttyS0 00:00:00 drrun 794 ttyS0 00:00:00 ps (gdb) shell cat /proc/791/maps 2aaaaaa000-2aaaacb000 r-xp 00000000 b3:04 1042887 /root/build_riscv64_backup/bin64/drrun 2aaaacb000-2aaaacc000 r--p 00020000 b3:04 1042887 /root/build_riscv64_backup/bin64/drrun 2aaaacc000-2aaaad2000 rw-p 00021000 b3:04 1042887 /root/build_riscv64_backup/bin64/drrun 2aaaad2000-2aaaae8000 rw-p 00000000 00:00 0 [heap] 3ff7e9c000-3ff7fbe000 r-xp 00000000 b3:04 2028 /lib/riscv64-linux-gnu/libc.so.6 3ff7fbe000-3ff7fc1000 r--p 00122000 b3:04 2028 /lib/riscv64-linux-gnu/libc.so.6 3ff7fc1000-3ff7fc3000 rw-p 00125000 b3:04 2028 /lib/riscv64-linux-gnu/libc.so.6 3ff7fc3000-3ff7fd0000 rw-p 00000000 00:00 0 3ff7fdd000-3ff7fdf000 rw-p 00000000 00:00 0 3ff7fdf000-3ff7fe0000 r--p 00000000 00:00 0 [vdso_data] 3ff7fe0000-3ff7fe1000 r-xp 00000000 00:00 0 [vdso] 3ff7fe1000-3ff7ffd000 r-xp 00000000 b3:04 2025 /lib/riscv64-linux-gnu/ld-linux-riscv64-lp64d.so.1 3ff7ffd000-3ff7ffe000 r--p 0001c000 b3:04 2025 /lib/riscv64-linux-gnu/ld-linux-riscv64-lp64d.so.1 3ff7ffe000-3ff8000000 rw-p 0001d000 b3:04 2025 /lib/riscv64-linux-gnu/ld-linux-riscv64-lp64d.so.1 3ffffdf000-4000000000 rw-p 00000000 00:00 0 [stack] (gdb) c Continuing. process 791 is executing new program: /root/build_riscv64_backup/lib64/release/libdynamorio.so Error in re-setting breakpoint 1: Function "main" not defined.

Program received signal SIGSEGV, Segmentation fault. instr_encode_arch (dcontext=dcontext@entry=0xffffffffffffffff, instr=instr@entry=0x3db3f50368, copy_pc=0x40b3ef50c0 <error: Cannot access memory at address 0x40b3ef50c0>, final_pc=final_pc@entry=0x40b3ef50c0 <error: Cannot access memory at address 0x40b3ef50c0>, check_reachable=check_reachable@entry=true, has_instr_opnds=has_instr_opnds@entry=0x0) at /data2/phase2/benchmarking/temp/dynamorio/core/ir/riscv64/encode.c:139 139 /data2/phase2/benchmarking/temp/dynamorio/core/ir/riscv64/encode.c: No such file or directory. (gdb) bt

0 instr_encode_arch (dcontext=dcontext@entry=0xffffffffffffffff,

instr=instr@entry=0x3db3f50368, 
copy_pc=0x40b3ef50c0 <error: Cannot access memory at address 0x40b3ef50c0>, final_pc=final_pc@entry=0x40b3ef50c0 <error: Cannot access memory at address 0x40b3ef50c0>, check_reachable=check_reachable@entry=true, 
has_instr_opnds=has_instr_opnds@entry=0x0)
at /data2/phase2/benchmarking/temp/dynamorio/core/ir/riscv64/encode.c:139

1 0x0000003ff7f7789a in instr_encode_to_copy (

drcontext=drcontext@entry=0xffffffffffffffff, 
instr=instr@entry=0x3db3f50368, copy_pc=<optimized out>, 
final_pc=final_pc@entry=0x40b3ef50c0 <error: Cannot access memory at address 0x40b3ef50c0>)
at /data2/phase2/benchmarking/temp/dynamorio/core/ir/encode_shared.c:134

2 0x0000003ff7f6eb00 in encode_with_patch_list (

dcontext=dcontext@entry=0xffffffffffffffff, 
patch=patch@entry=0x3fffffef70, ilist=ilist@entry=0x3fffffef48, 
start_pc=start_pc@entry=0x40b3ef50c0 <error: Cannot access memory at address 0x40b3ef50c0>)
at /data2/phase2/benchmarking/temp/dynamorio/core/arch/emit_utils_shared.c:1062

3 0x0000003ff7f6f44e in emit_fcache_enter_common (code=0x3fffffef48,

shared=true, absolute=false, 
pc=0x40b3ef50c0 <error: Cannot access memory at address 0x40b3ef50c0>, 

--Type for more, q to quit, c to continue without paging-- dcontext=0xffffffffffffffff) at /data2/phase2/benchmarking/temp/dynamorio/core/arch/emit_utils_shared.c:2185

4 emit_fcache_enter_shared (dcontext=dcontext@entry=0xffffffffffffffff,

code=code@entry=0x3fb3ef4000, 
pc=pc@entry=0x40b3ef50c0 <error: Cannot access memory at address 0x40b3ef50c0>)
at /data2/phase2/benchmarking/temp/dynamorio/core/arch/emit_utils_shared.c:2669

5 0x0000003ff7f69e12 in shared_gencode_emit (gencode=0x3fb3ef4000)

at /data2/phase2/benchmarking/temp/dynamorio/core/arch/arch.c:329

6 shared_gencode_init ()

at /data2/phase2/benchmarking/temp/dynamorio/core/arch/arch.c:564

7 d_r_arch_init ()

at /data2/phase2/benchmarking/temp/dynamorio/core/arch/arch.c:770
ksco commented 7 months ago

I am using dynamorio release 10.0.0

To try out RISC-V support, you should consider using the latest master tree.

akhileshkumar80 commented 7 months ago

I am using dynamorio release 10.0.0

To try out RISC-V support, you should consider using the latest master tree.

The reason i used 10.0.0 instead master i was getting below configure time issue., and i was unable to resold this with our source code update. Please let me know how can resolve this with our source code update ?

$ cmake -DCMAKE_TOOLCHAIN_FILE=../master/dynamorio/make/toolchain-aarch64.cmake ../master/dynamorio ----------------------------------------------cut---------------------------------- -- Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR) -- Performing Test implicit_fallthrough_avail -- Performing Test implicit_fallthrough_avail - Success -- Found Doxygen: /usr/bin/doxygen (found version "1.8.17") found components: doxygen dot -- Using vera++ for code style checks -- Using elfutils CMake Error at ext/drsyms/CMakeLists.txt:176 (message): Failed to find single source for /data2/phase2/benchmarking/master/dynamorio/ext/drsyms/elfutils/dwarf_begin_elf.c.patch

ksco commented 7 months ago

$ cmake -DCMAKE_TOOLCHAIN_FILE=../master/dynamorio/make/toolchain-aarch64.cmake ../master/dynamorio

The -DCMAKE_TOOLCHAIN_FILE option is for cross compiling, since you're compiling on the VisionFive SBC (I believe), it should be removed.

Failed to find single source for

You need to pull the submodules too.

Refer to https://dynamorio.org/page_building.html for building from source details.

derekbruening commented 7 months ago

RISC-V is indeed still under development which is why pre-compiled binaries are not yet supplied. Only some tools and small applications work at this point, is my understanding. If you would like to help with development or have further questions please reach out on the users list https://groups.google.com/forum/#!forum/DynamoRIO-Users