DynamoRIO / DynamoRIO/dynamorio

c++ stat crash in dr_client_main in Windows private libraries

Open
#7,220 2 comments 0 reactions 0 assignees View on GitHub
help wanted OpSys-Windows
Dominant language
C
Stars
3.2k
Forks
629
Avg merge
2d 15h
Merged PRs (30d)
31

Description

To get the file size, I do not want to open that file.
So, I use c++ "stat" function.
Here is the total function I use to get a file size without opening a file.

size_t get_file_size(const std::string& file_path)
{
size_t res = 0;
struct stat buf;
int result;
result = stat(file_path.c_str(), &buf);
if (result != 0) {
// cout << "file info error, file may not be existed." << endl;
}
else {
res = buf.st_size;
}
return res;
}

When I invoke this function in dr_client_main, the dynamorio crashes.
The crash point is when the stat is invoked.
I tested it in normal visual studio console applicaiton, the above function runs normally.

The Operating System is Windows 10.
DynamoRIO version is DynamoRIO-Windows-11.3.0-1.

Using -debug option, the output is:
Internal Error: DynamoRIO debug check failure: D:\a\dynamorio\dynamorio\core\win32\loader.c:777 !is_dynamo_address(dcontext->app_fls_data)
(Error occurred @0 frags in tid 27296)
version 11.3.0, build 1
It seems some loading dll error happens when I use "stat" function in client.

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.