src/common/system_utils_win32.cpp


Log

Author Commit Date CI Message
Tom Sepez 25390156 2025-08-21T00:13:19 Suppress unsafe buffers on a file-by-file basis in src/ [1 of N] In this CL, we suppress many files but stop short of actually enabling the warning by not removing the line from the unsafe_buffers_paths.txt file. That will happen in a follow-on CL, along with resolving any stragglers missed here. This is mostly a manual change so as to familiarize myself with the kinds of issues faced by the Angle codebase when applying buffer safety warnings. -- Re-generate affected hashes. -- Clang-format applied to all changed files. -- Add a few missing .reserve() calls to vectors as noticed. -- Fix some mismatches between file names and header comments. -- Be more consistent with header comment format (blank lines and trailing //-only lines when a filename comment adjoins license boilerplate). Bug: b/436880895 Change-Id: I3bde5cc2059acbe8345057289214f1a26f1c34aa Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6869022 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Roman Lavrov 67300089 2022-11-07T09:52:14 Improve error messages when failing to load a library. https://groups.google.com/g/angleproject/c/SE6zIKU9LzY/m/WvyFvPW1DQAJ Bug: None Change-Id: Id44d96e14f8cc6607c40c746d51719753f3904dc Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4008999 Commit-Queue: Roman Lavrov <romanl@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Auto-Submit: Roman Lavrov <romanl@google.com>
Jamie Madill b2c01ac4 2021-09-28T12:57:45 Report process memory in perf tests. Bug: angleproject:6440 Change-Id: Ifdd4389266e3ac55963a3069d437c631bf73f72a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3191194 Reviewed-by: Charlie Lao <cclao@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Yuxin Hu <yuxinhu@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Andrew Naumov d36df8d7 2022-02-10T15:12:01 Unicode support for system_utils on Windows Failed to load ANGLE_GLESV2_LIBRARY_NAME via ansi WinAPI if path contains unicode, use wide version instead. Bug: chromium:1296105 Change-Id: Ifae18b2aba83f3ae84954cc4dd9afc0e2c58834c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3452103 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
Jamie Madill 2d3ce72d 2022-01-20T10:13:06 Refactor shared library load to avoid allocations. Fixes a leak of an angle::Library detected in the EGL loader. Bug: angleproject:6937 Change-Id: I623aa6172b98a35465e1d2641b92f67bdc5d24e7 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3403060 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Yuly Novikov <ynovikov@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Alexis Hetu cac81f07 2021-12-14T22:56:15 Return full error info when opening a library with dlopen This CL adds a parameter to OpenSharedLibrary and OpenSharedLibraryWithExtension which is used to return the full path of the library which was opened. If dlopen failed, the string also contains the result of dlerror which explains what the error was. Bug: chromium:1246171 Change-Id: I374c7e2dfa18853c8137b4cbea06af8db3fdb501 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3340020 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Alexis Hétu <sugoi@chromium.org>
Lubosz Sarnecki 56aee5d6 2021-12-10T12:32:58 Reland "system_utils: Add memory protection functionality." This is a reland of b1c703e5f5e44514e8db958a5fb39ff16e514fd8 that was reverted in 663831aa676c59829cc3d822340812f016bf77f6. Skip PageFaultHandlerProtect and PageFaultHandlerDefaultHandler on macOS and Fuchsia. Original change's description: > Reland "system_utils: Add memory protection functionality." > > This is a reland of ab75a90ff4ecb9d99b5c72bde92222b07c285401 > that was reverted in b007e667a8f94b47788a5ba0b2e61c9ac2d1285f. > > Implement PageFaultHandler and memory protection functions. > Uses mprotect and sigaction on POSIX and equivalent Win API functions on > win32. > > Add tests to system_utils_unittests. > > Add stubs for winuwp. > > Replace ASSERT with ASSERT_TRUE in the PageFaultHandlerDefaultHandler > test to make it succeed on release builds, as the code was optimized > out. Furthermore the test did not correctly remove protection from the > whole area it protected, which caused a hang after deinitialization on > some build configurations, since the custom page fault handler was also > still in place. The test now correclty removes protection from the whole > area and sets back the original page fault handler. > > Test: angle_unittests --gtest_filter="SystemUtils.PageFaultHandler*" > Bug: angleproject:5857 > Change-Id: Ibb0acfefd9a09c3360c04c812a2a8346b951e1da > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3322992 > Reviewed-by: Jamie Madill <jmadill@chromium.org> > Commit-Queue: Lubosz Sarnecki <lubosz.sarnecki@collabora.com> Test: angle_unittests --gtest_filter="SystemUtils.PageFaultHandler*" Bug: angleproject:5857 Change-Id: Ifaa966a7c569aa9ff0112897a02fa8f873cd52dd Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3329610 Reviewed-by: Cody Northrop <cnorthrop@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Lubosz Sarnecki <lubosz.sarnecki@collabora.com>
Alexis Hetu f7d92a32 2021-12-10T10:23:32 Add debug info when loading EGL entry points fails Mac11 bots are often failing with the: "Error loading EGL entry points" error for an unknown reason. This CL adds the library path to the error message to see if it's trying to open the correct file. Bug: chromium:1277690 Change-Id: Ieb73a3097702933a89794d92c19ee44a6301c169 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3330576 Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Commit-Queue: Alexis Hétu <sugoi@chromium.org>
Jamie Madill 663831aa 2021-12-09T18:08:28 Revert "Reland "system_utils: Add memory protection functionality."" This reverts commit b1c703e5f5e44514e8db958a5fb39ff16e514fd8. Reason for revert: Fails on fuchsia bots: https://ci.chromium.org/ui/p/chromium/builders/try/fuchsia_arm64/1020498/overview mprotect failed: Not supported Original change's description: > Reland "system_utils: Add memory protection functionality." > > This is a reland of ab75a90ff4ecb9d99b5c72bde92222b07c285401 > that was reverted in b007e667a8f94b47788a5ba0b2e61c9ac2d1285f. > > Implement PageFaultHandler and memory protection functions. > Uses mprotect and sigaction on POSIX and equivalent Win API functions on > win32. > > Add tests to system_utils_unittests. > > Add stubs for winuwp. > > Replace ASSERT with ASSERT_TRUE in the PageFaultHandlerDefaultHandler > test to make it succeed on release builds, as the code was optimized > out. Furthermore the test did not correctly remove protection from the > whole area it protected, which caused a hang after deinitialization on > some build configurations, since the custom page fault handler was also > still in place. The test now correclty removes protection from the whole > area and sets back the original page fault handler. > > Test: angle_unittests --gtest_filter="SystemUtils.PageFaultHandler*" > Bug: angleproject:5857 > Change-Id: Ibb0acfefd9a09c3360c04c812a2a8346b951e1da > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3322992 > Reviewed-by: Jamie Madill <jmadill@chromium.org> > Commit-Queue: Lubosz Sarnecki <lubosz.sarnecki@collabora.com> Bug: angleproject:5857 Change-Id: Iaab4067a7ec9240bb6c64b810ac6d3ea7bd86fe1 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3327743 Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Lubosz Sarnecki b1c703e5 2021-12-08T14:53:46 Reland "system_utils: Add memory protection functionality." This is a reland of ab75a90ff4ecb9d99b5c72bde92222b07c285401 that was reverted in b007e667a8f94b47788a5ba0b2e61c9ac2d1285f. Implement PageFaultHandler and memory protection functions. Uses mprotect and sigaction on POSIX and equivalent Win API functions on win32. Add tests to system_utils_unittests. Add stubs for winuwp. Replace ASSERT with ASSERT_TRUE in the PageFaultHandlerDefaultHandler test to make it succeed on release builds, as the code was optimized out. Furthermore the test did not correctly remove protection from the whole area it protected, which caused a hang after deinitialization on some build configurations, since the custom page fault handler was also still in place. The test now correclty removes protection from the whole area and sets back the original page fault handler. Test: angle_unittests --gtest_filter="SystemUtils.PageFaultHandler*" Bug: angleproject:5857 Change-Id: Ibb0acfefd9a09c3360c04c812a2a8346b951e1da Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3322992 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Lubosz Sarnecki <lubosz.sarnecki@collabora.com>
Kai Ninomiya b007e667 2021-12-08T01:00:54 Revert "system_utils: Add memory protection functionality." This reverts commit ab75a90ff4ecb9d99b5c72bde92222b07c285401. Reason for revert: Causes angle_unittests to hang on many Linux FYI bots and likely Android. First known failures on Linux: https://ci.chromium.org/ui/p/chromium/builders/ci/Linux%20FYI%20Release%20(AMD%20RX%205500%20XT)/7318/overview https://ci.chromium.org/ui/p/chromium/builders/ci/Linux%20FYI%20Release%20(Intel%20HD%20630)/30297/overview https://ci.chromium.org/ui/p/chromium/builders/ci/Linux%20FYI%20Experimental%20Release%20(Intel%20HD%20630)/43446/overview https://ci.chromium.org/ui/p/chromium/builders/ci/Linux%20FYI%20Release%20(Intel%20UHD%20630)/4720/overview https://ci.chromium.org/ui/p/chromium/builders/ci/Linux%20FYI%20Release%20(NVIDIA)/29040/overview https://ci.chromium.org/ui/p/chromium/builders/ci/Linux%20FYI%20Experimental%20Release%20(NVIDIA)/45374/overview And Android: https://ci.chromium.org/ui/p/chromium/builders/ci/Android%20FYI%20Release%20(Nexus%209)/35989/overview https://ci.chromium.org/ui/p/chromium/builders/ci/Android%20FYI%20Release%20(NVIDIA%20Shield%20TV)/33490/overview Original change's description: > system_utils: Add memory protection functionality. > > Implement PageFaultHandler and memory protection functions. > Uses mprotect and sigaction on POSIX and equivalent Win API functions on > win32. > > Add tests to system_utils_unittests. > > Add stubs for winuwp. > > Test: angle_unittests --gtest_filter="SystemUtils.PageFaultHandler*" > Bug: angleproject:5857 > Change-Id: Ia6d2e87c409e6139ccaebc8c7186cd4cd844fd28 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3236998 > Reviewed-by: Jamie Madill <jmadill@chromium.org> > Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> > Reviewed-by: Cody Northrop <cnorthrop@google.com> > Commit-Queue: Lubosz Sarnecki <lubosz.sarnecki@collabora.com> Bug: angleproject:5857 Change-Id: I7df73a3ee3f5fa87f002045dfa87d8ca2747f60f No-Tree-Checks: true Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3322104 Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Commit-Queue: Kai Ninomiya <kainino@chromium.org> Reviewed-by: Tim Van Patten <timvp@google.com> Commit-Queue: Tim Van Patten <timvp@google.com>
Lubosz Sarnecki ab75a90f 2021-10-21T20:20:07 system_utils: Add memory protection functionality. Implement PageFaultHandler and memory protection functions. Uses mprotect and sigaction on POSIX and equivalent Win API functions on win32. Add tests to system_utils_unittests. Add stubs for winuwp. Test: angle_unittests --gtest_filter="SystemUtils.PageFaultHandler*" Bug: angleproject:5857 Change-Id: Ia6d2e87c409e6139ccaebc8c7186cd4cd844fd28 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3236998 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: Lubosz Sarnecki <lubosz.sarnecki@collabora.com>
Steven Noonan be947198 2021-10-20T17:33:34 avoid reading past end of stack array in GetEnvironmentVar I ran into a case where GetEnvironmentVariableA returned a nonzero value, but std::string() read past the end of the oldValue array when it tried to strlen() it. It seems it tried to read an environment variable that was already huge, because MSDN says: If lpBuffer is not large enough to hold the data, the return value is the buffer size, in characters, required to hold the string and its terminating null character and the contents of lpBuffer are undefined. So if the buffer isn't large enough, it doesn't just truncate the value (like GetModuleFilenameA would). It instead returns the size we would need to allocate to store the value. It also vaguely states that the contents of the buffer are undefined in this scenario, which means that the std::array used here could still be filled with uninitialized data without a null character in there. A better solution here is to use a FastVector, so we can resize it to fit whatever variable we're reading (MSDN states the maximum environment variable size is 32,767 characters, including the null terminator -- not MAX_PATH as this code seems to have assumed). Bug: angleproject:6600 Change-Id: I1582867578c5b879e71d58ab494a5134848b180f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3235902 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Jamie Madill 48da1c35 2021-07-16T13:24:34 Vulkan: Prefer the local vulkan loader over the system one. Load the Vulkan loader ourselves and give vkGetInstanceProcAddr to volk. This allows us to always prefer loading from the current module directory instead of using the platform-specific ordering. Refactor angle::Library loading to use ModuleDir instead of ApplicationDir. CL originally authored by Geoff Lang. Bug: chromium:1219969 Change-Id: I21d1926e90fd66e1c23cea7323991ae55f3d22d4 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3035444 Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Tim Van Patten <timvp@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Jamie Madill 51937ab3 2021-06-25T09:10:42 Re-land "Add SearchType to OpenSharedLibraryWithExtension." This fixes a bug in SystemInfo_vulkan where we were using the System search path for the Vulkan loader when we prefer using the custom ANGLE loader. Re-land fixes a bug where we would try to load the custom libVulkan on Android and other platforms where we should be using the system version. Bug: chromium:1219969 Change-Id: I34b592fb87cbddfd02c837a17942cac54c85d9d1 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3007265 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Yuly Novikov f8d5d5ed 2021-07-05T21:11:23 Revert "Add SearchType to OpenSharedLibraryWithExtension." This reverts commit 18e99f4a2b37468b103da4a56c5b0fff25458062. Reason for revert: breaks Mac, e.g. https://ci.chromium.org/ui/p/chromium/builders/ci/mac-arm64-rel-tests/2197/overview Original change's description: > Add SearchType to OpenSharedLibraryWithExtension. > > This fixes a bug in SystemInfo_vulkan where we were using the > System search path for the Vulkan loader when we prefer using the > custom ANGLE loader. > > Bug: chromium:1219969 > Change-Id: Iedf0fd11fe9ed8cc020b445ea9e12a7936937361 > Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2988791 > Reviewed-by: Jamie Madill <jmadill@chromium.org> > Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> > Commit-Queue: Jamie Madill <jmadill@chromium.org> Bug: chromium:1219969, chromium:1225040, chromium:1226675 Change-Id: I7a7e329181b69b0fb546e5245d8842723077126f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3006320 Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Reviewed-by: Yuly Novikov <ynovikov@chromium.org> Commit-Queue: Yuly Novikov <ynovikov@chromium.org>
Jamie Madill 18e99f4a 2021-06-25T09:10:42 Add SearchType to OpenSharedLibraryWithExtension. This fixes a bug in SystemInfo_vulkan where we were using the System search path for the Vulkan loader when we prefer using the custom ANGLE loader. Bug: chromium:1219969 Change-Id: Iedf0fd11fe9ed8cc020b445ea9e12a7936937361 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2988791 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Shahbaz Youssefi 7df7fc7f 2021-06-20T00:05:28 Tests: Add support for --renderdoc This change adds support for a new flag namely `--renderdoc` to end2end and deqp tests. With this flag, each test automatically starts and ends a frame capture in renderdoc, working around an issue where renderdoc refuses to capture a test frame that doesn't start or end with a swap. With end2end tests, the capture starts before test set up, and ends after test tear down. With deqp tests, it starts before init, ends and restarts after each test iteration and ends after deinit. Bug: angleproject:6072 Change-Id: Ib41b816aff121bf922d9147044cc363c33a62181 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2971835 Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Cody Northrop <cnorthrop@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill 78dde332 2021-03-29T17:31:52 Move restricted traces to CIPD. All traces are now stored as DEPS entries in CIPD. The auto-generation script generates the DEPS entries. Note that we don't include DEPS in the list of generated outputs to simplify other rollers. Also we update auto-generation to include full sources list to allow 'gn analyze' to work successfully. Usees a trace fixture for common code. This will enable a more compact trace without as much repeated code. We must land a set of re-trace traces to avoid breakage. Also includes a python script for uploading new traces to CIPD. The script first checks if traces are already present in the cloud, and if so it skips the upload. It will take a while to complete as the number of traces grows larger as it takes a few seconds per trace. The traces in this patch are also re-traced to use the common fixture code instead of including duplicated code in each trace. They now form a simple common interface and the autogenerated cpp is now simply a list of properties. I've also updated the capture/replay tests to use the simpler common entry point integration. There is less auto-generated glue code now. We now use a new serialized string query extension instead of calling directly into ANGLE's internals. Also includes a docs update. The capture/replay sample is broken and we'll need to update it in a follow-up CL. Also includes a few necessary fixes to the retracing script. Bug: angleproject:5811 Change-Id: I977bc6dc56843c8966377fc445ae97e91e17319a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2797833 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Cody Northrop <cnorthrop@google.com> Reviewed-by: Tim Van Patten <timvp@google.com>
Jamie Madill 930b2641 2020-03-23T14:47:03 Allow tests to run on native EGL. Adds support for Linux and Android native EGL testing. This can be useful for doing performance comparisons of ANGLE vs a native GL driver. Only enabled for the trace perf tests due to limitations in the test harness. Bug: angleproject:4596 Change-Id: Iba6d3ccd7c1275cf095893fab824a0ea33dc3a79 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2116254 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Yuly Novikov <ynovikov@chromium.org>
Jamie Madill 5eadaf85 2020-01-13T17:21:53 Fix and improve UWP build. Reorganizes the build files to work with a more divided setup. It is unclear if we'll ever be able to run tests in a UWP config. This at least sets up the organization so it would at some point be possible. Bug: angleproject:4182 Change-Id: I49dddfcdc0118b11466fe171f949c28d101ac6a2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1953484 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Yuly Novikov <ynovikov@chromium.org>