[CRASH] Failure on some functions of the standard library on new Windows 10
Created by: fedor-niskov
Describe the bug
When DR client invokes some standard library functions (for example, localtime_s
or std::mutex
), execution suddenly hangs for a second, then just stops - it finishes silently, without any error messages (neither GUI nor command-line). I would call it a silent crash (hence the category of this issue). It happens with any application under new DynamoRIO on new Windows 10. It seems that the process just exits (but with a strange exit code: echo %errorlevel%
shows -529697949
).
To Reproduce
It's pretty simple to reproduce the bug: we need to write a tiny client invoking a problematic function, compile it using standard cmake way for DR, and run with any application (some "HelloWorld").
Example 1 - std::mutex
The client (include headers omitted):
void dr_client_main(client_id_t id, int argc, const char *argv[]) {
dr_printf("dr_client_main\n");
std::mutex mtx;
mtx.lock();
mtx.unlock();
dr_printf("OK\n");
}
Run:
dr\bin64\drrun.exe -c client.dll -- prog.exe
Output:
dr_client_main
Example 2 - localtime_s
The client:
void dr_client_main(client_id_t id, int argc, const char *argv[]) {
dr_printf("dr_client_main\n");
struct tm stm;
time_t t = time(NULL);
dr_printf("localtime_s\n");
localtime_s(&stm, &t);
dr_printf("OK\n");
}
Output:
dr_client_main
localtime_s
Expected behavior
Standard library functions should work properly (I have faced only these two cases, maybe other examples exist).
Versions
DynamoRIO - version 8.0.0-1 (downloaded from the official website)
OS Windows 10 - version 2004 (build 19041.508) This is a VirtualBox machine by Microsoft: https://developer.microsoft.com/en-us/windows/downloads/virtual-machines/
64-bit
Additional context
When the target application uses the aforementioned functions - it works OK; the problem is only when the client does.
These examples work normally on Linux.
I can use DR API analogues instead of these functions, of course, but it doesn't allow me to use some third-party libraries (for example, spdlog) which can invoke various standard library functions.
I have tried to perform a debug run (dr\bin64\drrun.exe -debug -c client.dll -- prog.exe
). However, it always fails, even with client/application which work properly without debug. The output:
<Starting application F:\dir\expr\dr\issue\1\prog.exe (2720)>
<cannot remove dll from rbtree: at root/min + can't find real tree>
<Running on newer-than-this-build "Microsoft Windows 10-2004 x64">
<Early threads found>
<Application F:\dir\expr\dr\issue\1\prog.exe (2720). Internal Error: DynamoRIO debug check failure: ..\..\core\win32\drwinapi\kernel32_file.c:113 NT_SUCCESS(res)
(Error occurred @0 frags)
version 8.0.0, build 1
-no_dynamic_options -client_lib 'F:\dir\expr\dr\issue\1\client.dll;0;' -code_api -probe_api -stack_size 56K -max_elide_jmp 0 -max_elide_call 0 -no_inline_ignored_syscalls -native_exec_default_list '' -no_native_exec_managed_code -no_indcall2direct >