DynamoRIO / DynamoRIO/drmemory
Nudge test fails on Windows with TEB in the wrong state
- Dominant language
- C
- Stars
- 2.7k
- Forks
- 290
- PR merge metrics
- No merged PRs in 30d
Description
The nudge test does not work in one of my msys environments, though it does work in other msys environments:
1. The first nudge is received correctly, and the leak status is reported to the log.
2. During `nudge_thread_cleanup()` the TEB is switched back to app: `swap_peb_pointer(dcontext, false/*to app*/)`
3. The same thread is somehow reaching `redirect_heap_call()` without making an app exit to DR, resulting in an assert failure on `os_using_app_state()`.
The test passes when I disable the `swap_peb_pointer()` in `nudge_thread_cleanup()`, though it seems like that may cause failures on other machines (for the same basic reason). A better solution might be to swap the TEB at some later point when there is no possibility of using the TEB before actually going back to the app.
There are some other issues with the test that could be improved:
1. The error strings in runtest.cmake need to be more clear about what exactly failed. For example, if the second nudge failed, it should say that the first one succeeded but the second one failed.
2. The dynamorio assert failure does not appear anywhere in the drmemory log. There could be a simple callback-on-assert for clients, allowing them to log the fact that some assert happened in DR (not necessarily with any details).
3. An outline of the nudge test needs to be documented somewhere. Currently there is no source file for the nudge test, since it just runs `infloop`. The procedure for handling the nudge test in `runtest.cmake` doesn't have any doc section showing how the test is meant to work.
4. It could be easier to get a dynamorio log for a drmemory test, for example via environment variable. Currently the only way is to tweak the cmake by adding the following to `-dr_ops`, which for Windows requires special knowledge that (a) the log dir must be an absolute path and (b) the backslashes must be double-escaped:
`-logdir c:\\\\dev\\\\dr-logs -loglevel 1`
Contributor guide
Assessment
This issue has not been assessed yet.