-
Notifications
You must be signed in to change notification settings - Fork 397
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
Fix omrsysinfo_get_memory_info for non-english locales on windows #7566
base: master
Are you sure you want to change the base?
Conversation
The windows implementation of omrsysinfo_get_memory_info used PdhAddCounter which requires the counter path string to be localized. Since we weren't doing so the function failed on non-english windows systems. Replacing the call with the language neutral PdhAddEnglishCounter fixes the problem. I added some debug to check and print the error code. Before the change: ``` omrsysinfo_get_memory_info: after GlobalMemoryStatusEx 4200 omrsysinfo_get_memory_info: after PdhOpenQuery 189500 omrsysinfo_get_memory_info: after PdhAddCounter 1 532003600 PdhAddCounter FAILED with c0000bb8 ``` After the change: ``` omrsysinfo_get_memory_info: after GlobalMemoryStatusEx 5000 omrsysinfo_get_memory_info: after PdhOpenQuery 108600 omrsysinfo_get_memory_info: after PdhAddCounter 1 689300300 omrsysinfo_get_memory_info: after PdhAddCounter 2 309400 omrsysinfo_get_memory_info: after PdhAddCounter 3 161600 omrsysinfo_get_memory_info: after PdhCollectQueryData 201400 totalSwap 46477017088 ```
@babsingh : please review |
Commit guidelines: https://github.com/eclipse-omr/omr/blob/master/CONTRIBUTING.md#commit-guidelines
|
Co-authored-by: Babneet Singh <[email protected]>
Co-authored-by: Babneet Singh <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The commits will need to be squashed. The primary commit will need to be updated as per #7566 (comment).
if (ERROR_SUCCESS != status) { | ||
Trc_PRT_sysinfo_get_memory_info_failedAddingCounter("Commit Limit", status); | ||
Trc_PRT_sysinfo_get_memory_info_Exit(OMRPORT_ERROR_SYSINFO_ERROR_READING_MEMORY_INFO); | ||
PdhCloseQuery(statsHandle); | ||
return OMRPORT_ERROR_SYSINFO_ERROR_READING_MEMORY_INFO; | ||
} | ||
|
||
status = PdhAddCounter(statsHandle, | ||
status = PdhAddEnglishCounter(statsHandle, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#7566 (comment) also needs to be applied here.
@@ -951,7 +953,7 @@ omrsysinfo_get_memory_info(struct OMRPortLibrary *portLibrary, struct J9MemoryIn | |||
return OMRPORT_ERROR_SYSINFO_ERROR_READING_MEMORY_INFO; | |||
} | |||
|
|||
status = PdhAddCounter(statsHandle, | |||
status = PdhAddEnglishCounter(statsHandle, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#7566 (comment) also needs to be applied here.
The windows implementation of omrsysinfo_get_memory_info used PdhAddCounter which requires the counter path string to be localized. Since we weren't doing so the function failed on non-english windows systems. Replacing the call with the language neutral PdhAddEnglishCounter fixes the problem.
I added some debug to check and print the error code, and tested by setting Windows to the French locale.
Before the change:
After the change:
Doc for PdhAddEnglishCounter: https://learn.microsoft.com/en-us/windows/win32/api/pdh/nf-pdh-pdhaddenglishcountera