-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
src: fix bugs and refactor NativeSymbolDebuggingContext::GetLoadedLibraries #57738
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This comment was marked as off-topic.
This comment was marked as off-topic.
missing parenthesis format c++
8aea264
to
80624e0
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #57738 +/- ##
=======================================
Coverage 90.24% 90.25%
=======================================
Files 630 630
Lines 184949 184989 +40
Branches 36207 36218 +11
=======================================
+ Hits 166902 166954 +52
+ Misses 11002 10997 -5
+ Partials 7045 7038 -7
🚀 New features to boost your workflow:
|
@addaleax There seems to be a fair amount of Builds that failed on pummel.test-buffer-large-size due to a timeout after 12mins, like this one. Is this a test that's known to fail from time to time? |
@H4ad if you have a moment, does the build failure I linked in the comment above look to be from a flaky test? The code I changed shouldn't have affected this test, and there's a pattern of timeout failures for this test on other builds too. If that is the case, could you add the request-ci label again? I think it just needs to be re-run. |
Looks like a flaky test, I resume the CI in the Jenkins, you can ask to resume the CI instead of add request-ci again, adding the label again will re-run all the tests again (instead of just the one that failed) |
@H4ad A test that completed w/ "unstable" last time failed this time, but it seems the test never actually ran. It died while being setup. Are there some artifacts relative to the initial ci run that no longer exist? Hopefully that doesn't mean having to re-run more than what failed 😅
|
friendly ping to @nodejs/platform-windows before adding commit-queue |
tldr:
GetLoadedLibraries is used in process.report.GetReport to generate a list of loaded libraries. This PR fixes the following:
--
Refactor:
Sources from Docs + Raymond Chen
"To retrieve the name of a module in the current process, use the GetModuleFileName function" -- WinApi Docs: Remarks
Raymond Chen explains how GetModuleFileNameExW can fail randomly, in a way that GetModuleFileNameW avoids -- Article
Bug Fixes:
modules
allocates memory by multiplying the constructor argsize_t n
by thesizeof
it's type. In this case,modules
would be allocated withsize_1 * sizeof(HMODULE)
bytes. But EnumProcessModules setssize_1
to the number of bytes that need to be allocated for themodule
buffer. Usingsize_1/sizeof(HMODULE)
gives the constructor what it's asking for i.e the number of HMODULES to allocate space for.Exapnd to Step through MallocedBuffer constructor behavior
src/util.h MallocedBuffer
src/util-inl.h UncheckedMalloc
src/util-inl.h UncheckedRealloc
src/util-inl.h MultiplyWithOverflowCheck
Unnecessary Module path truncation: GetModuleFileName is called using
array_size(module_name) / sizeof(WCHAR)
for thenSize
param.nSize
is supposed to be the number of characters in the wchar array supplied.module_name
is already a WCHAR array, sonSize
should just bearray_size(module_name)
. The current code causes GetModuleFileName to truncate after reaching half the capacity of the buffer (i.e half of MAX_PATH)Memory Leak: When converting the file path written by GetModuleFileName from a wchar array to a char array with UTF8 encoding, a char array
str
is added to the heap usingnew
. Next, it's added tolist
, astd::vector<std::string>
usingemplace_back
.emplace_back
will passstr
intro thestd::string
constructor. This constructor is defined to copy values from a null terminatedchar * array
into thestd::string
. I assumestr
was created on the heap so that it could be dynamically allocated based on the number of bytes returned byWideCharToMultiByte
. Once it's added tolist
, the memory is no longer needed, but is never deleted from the heap.