DynamoRIO / DynamoRIO/dynamorio

HANG assert failure causes hang in drcachesim

Open
#4,376 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
3.2k
Forks
629
Avg merge
2d 15h
Merged PRs (30d)
31

Description

**Describe the bug**
While working on #4341 I noticed that failure of `DR_ASSERT` causes a hang in `drcachesim`, which then needs to be terminated manually.

**To reproduce**

1. Patch the following diff. It causes the assert failure, which reveals the bug.
```
clients/drcachesim/tests/allasm_aarch64_prefetch.asm
@@ -163,6 +163,8 @@ _start:
prfum pstl3strm, [x1]
prfum pstl3strm, [x1]

+ prfum 28, [x1]
+
// Exit.
mov w0, #1 // stdout
adr x1, helloworld

```
2. On an AArch64 machine, run the following commands
```
cmake -DDEBUG=ON -DBUILD_TESTS=ON
make -j
./bin64/drrun -t drcachesim -- suite/tests/bin/allasm_aarch64_prefetch
```
3. This will cause an assert failure at https://github.com/DynamoRIO/dynamorio/blob/cdc24cb13514cca50012dc9397b446323ddd62c5/clients/drcachesim/tracer/instru.cpp#L147
```
ASSERT FAILURE: /home/abhinavas/dr/src/i4328-1/clients/drcachesim/tracer/instru.cpp:147: false (Unsupported AArch64 prefetch operation.)
```
But the process does not exit.

`ps -x` output:
```
abhinavas@tx1:~$ ps -x
PID TTY STAT TIME COMMAND
...
50632 pts/4 R+ 0:02 /home/abhinavas/dr/build/i4328-1/bin64/../clients/bin64/drcachesim -dr /home/abhinavas/dr/build/i4328-1/bin64/.. -dr_ops -tracer /home/abhinavas/dr/build/i4328-1/bin64/../clients/lib64/debug/libdrmemtrace.so -tracer_alt /home/abhinavas/dr/build/i4328
50633 pts/4 Z+ 0:00 [allasm_aarch64_]
...
```
The test app (`allasm_aarch64_prefetch`) is shown as defunct and the `drcachesim` process is still running. Based on `man`:
```
Processes marked are dead processes (so-called "zombies")
that remain because their parent has not destroyed them properly.
```

- What happens when you run without any client?
No issues.
- What happens when you run with debug build ("-debug" flag to drrun/drconfig/drinject)?
Same issue with `-dr_debug`

**Expected behavior**
`drcachesim` and test app should exit properly after the assert failure

**Versions**
- What version of DynamoRIO are you using?
At commit cdc24cb

- What operating system version are you running on?
Debian GNU/Linux 9.5 (stretch) on AArch64

- Is your application 32-bit or 64-bit?
64-bit

**Additional context**
I found that after adding `-dr_ops -unsafe_build_ldstex` and `setarch`, the processes exit as expected.
```
./bin64/drrun -t drcachesim -dr_ops -unsafe_build_ldstex -- setarch `uname -m` -R suite/tests/bin/allasm_aarch64_prefetch
```
I confirmed that both the additional options are required.

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.