DynamoRIO / DynamoRIO/dynamorio

APP CRASH (Access Violation 0xc0000005): drmgr_register_exception_event causes app crash in windows

Open
#6,129 1 comment 0 reactions 0 assignees View on GitHub
Bug-AppCrash help wanted OpSys-Windows
Dominant language
C
Stars
3.2k
Forks
629
Avg merge
2d 15h
Merged PRs (30d)
31

Description

**Describe the bug**
drmgr_register_exception_event causes app crash in windows. This happens for almost all executables as long as drmgr_register_exception_event is used in my DR client.

**To Reproduce**
The problematic DR code:
```
#include
#include
#include

#include "dr_api.h"
#include "drmgr.h"
#include "drx.h"
#include "drreg.h"

static bool exception_event(void *drcontext, dr_exception_t *excpt)
{
DWORD exception_code = excpt->record->ExceptionCode;
if(exception_code == EXCEPTION_ACCESS_VIOLATION)
{
dr_printf("Process crash(exception code: 0x%x)", exception_code);
dr_exit_process(-1);
}
return true;
}

DR_EXPORT void dr_client_main(client_id_t id, int argc, const char *argv[])
{
if(!drmgr_init())
{
DR_ASSERT_MSG(false, "DynamoRIO init failed.");
}

dr_enable_console_printing();
drmgr_register_exception_event(exception_event); // problematic line, app crash is triggered by this line
}
```

Compile it to "test.dll", and using windows default calculator and notepad as examples, exception code 0xc0000005 will be catched.
```
.\dynamorio\bin64\drrun.exe -c C:\Users\19730\projects\tools\dynamorio_issue_env\exception_detect\build\Debug\test.dll -- C:\Windows\System32\calc.exe
Process crash(exception code: 0xc0000005)

.\dynamorio\bin64\drrun.exe -c C:\Users\19730\projects\tools\dynamorio_issue_env\exception_detect\build\Debug\test.dll -- C:\Windows\System32\notepad.exe
Process crash(exception code: 0xc0000005)
```
I'm sure the crash is not related to permission issues as executables which are not under windows system path will also crash.

**Versions**
DynamoRIO version: DynamoRIO-Windows-9.93.19510
OS: Windows 10 19045.2965

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.