Skip to content

Commit

Permalink
i#2156: symbol fetch failures on Appveyor (#2158)
Browse files Browse the repository at this point in the history
Update DR to d11b7a99 for the drfront_fetch_module_symbols() workaround for
older dbghelp versions.

Remove the flaky markers for drstrace_unit_tests and syscall_file_gen as
these tests now work on Appveyor.

Adjust #1848's drsys_find_sysnum_libs() to check readability to skip dlls that do not exist on this OS version (e.g., win32u.dll)
Adjusts drsys_generate_sysnum_file() to avoid duplicates in interpolated usercalls.

Issue: #1848 
Fixes #2156
  • Loading branch information
derekbruening authored Feb 25, 2019
1 parent e40f342 commit f7eb0ad
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 19 deletions.
54 changes: 42 additions & 12 deletions drsyscall/pdb2sysfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,16 +399,10 @@ drsys_find_sysnum_libs(OUT char **sysnum_lib_paths, INOUT size_t *num_sysnum_lib
{
if (num_sysnum_libs == nullptr)
return DRMF_ERROR_INVALID_PARAMETER;
if (*num_sysnum_libs < NUM_SYSCALL_DLLS) {
*num_sysnum_libs = NUM_SYSCALL_DLLS;
return DRMF_ERROR_INVALID_SIZE;
}
if (sysnum_lib_paths == nullptr)
return DRMF_ERROR_INVALID_PARAMETER;
*num_sysnum_libs = NUM_SYSCALL_DLLS;

/* First, get %SystemRoot%. */
TCHAR system_rootw[MAXIMUM_PATH];
char system_root[MAXIMUM_PATH];
/* Get %SystemRoot%. */
DWORD len = GetWindowsDirectory(system_rootw, BUFFER_SIZE_ELEMENTS(system_rootw));
if (len == 0) {
_tcsncpy(system_rootw, _T("C:\\Windows"), BUFFER_SIZE_ELEMENTS(system_rootw));
Expand All @@ -419,10 +413,44 @@ drsys_find_sysnum_libs(OUT char **sysnum_lib_paths, INOUT size_t *num_sysnum_lib
NOTIFY(0, "Failed to determine system root" NL);
return DRMF_ERROR_NOT_FOUND;
}

/* Next, get the count of dlls that exist on this machine
* (win32u.dll and kernelbase.dll do not exist on older Windows).
*/
int count = 0;
int dll_readable[NUM_SYSCALL_DLLS];
char buf[MAXIMUM_PATH];
for (int i = 0; i < NUM_SYSCALL_DLLS; ++i) {
bool readable;
_snprintf(buf, BUFFER_SIZE_ELEMENTS(buf), "%s%csystem32%c%s",
system_root, DIRSEP, DIRSEP, syscall_dlls[i]);
NULL_TERMINATE_BUFFER(buf);
if (drfront_access(buf, DRFRONT_READ, &readable) == DRFRONT_SUCCESS &&
readable) {
NOTIFY(1, "%s: %s is readable" NL, __FUNCTION__, buf);
dll_readable[i] = true;
++count;
} else {
NOTIFY(1, "%s: %s is NOT readable" NL, __FUNCTION__, buf);
dll_readable[i] = false;
}
}

if (*num_sysnum_libs < count) {
*num_sysnum_libs = count;
return DRMF_ERROR_INVALID_SIZE;
}
if (sysnum_lib_paths == nullptr)
return DRMF_ERROR_INVALID_PARAMETER;
*num_sysnum_libs = count;
int index = 0;
for (int i = 0; i < NUM_SYSCALL_DLLS; ++i) {
_snprintf(sysnum_lib_paths[i], MAXIMUM_PATH, "%s%csystem32%c%s",
if (!dll_readable[i])
continue;
_snprintf(sysnum_lib_paths[index], MAXIMUM_PATH, "%s%csystem32%c%s",
system_root, DIRSEP, DIRSEP, syscall_dlls[i]);
sysnum_lib_paths[i][MAXIMUM_PATH-1] = '\0';
sysnum_lib_paths[index][MAXIMUM_PATH-1] = '\0';
++index;
}
return DRMF_SUCCESS;
}
Expand Down Expand Up @@ -884,9 +912,11 @@ write_file(const std::unordered_map<std::string, int> &name2num, const std::stri
else if (w15 != -1) { /* Assume once gone it's not coming back */ \
++num; \
/* If an entry was removed we'll collide. Just skip in that case. */\
/* Since the table order is not perfect we'll miss some. */\
if (num2name.find(num) == num2name.end()) { \
NOTIFY(2, "%s == 0x%x" NL, sysname.c_str(), num); \
dr_fprintf(f, "%s=0x%x\n", sysname.c_str(), num); \
NOTIFY(2, "%s == 0x%x" NL, sysname.c_str(), num); \
dr_fprintf(f, "%s=0x%x\n", sysname.c_str(), num); \
num2name[num] = sysname; \
}\
} \
} while (false);
Expand Down
2 changes: 1 addition & 1 deletion dynamorio
8 changes: 2 additions & 6 deletions tests/runsuite_wrapper.pl
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,10 @@
'malloc_callstacks' => 1,
'wrap_wincrt' => 1, # i#1741: flaky.
'app_suite.pattern' => 1,
'app_suite' => 1,
'drstrace_unit_tests' => 1, # i#2156: sym fetch
'syscall_file_gen' => 1); # i#2156: sym fetch
'app_suite' => 1);
%ignore_failures_64 = ('handle' => 1,
'app_suite' => 1,
'app_suite.pattern' => 1,
'drstrace_unit_tests' => 1, # i#2156: sym fetch
'syscall_file_gen' => 1); # i#2156: sym fetch
'app_suite.pattern' => 1);
} elsif ($^O eq 'darwin' || $^O eq 'MacOS') {
%ignore_failures_32 = ('malloc' => 1); # i#2038
%ignore_failures_64 = ('malloc' => 1);
Expand Down

0 comments on commit f7eb0ad

Please sign in to comment.