From 09a12170263aac916753e4d8e4e31eeddc3e35aa Mon Sep 17 00:00:00 2001 From: leileizhang Date: Wed, 3 Sep 2025 13:56:51 +0800 Subject: [PATCH] Fixed a memory alignment issue that caused the measure tool to crash on some machines. (#41556) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary of the Pull Request The EXCEPTION_DATATYPE_MISALIGNMENT error is a classic memory alignment issue, and add alignas(8) to Ensures cursorPosSystemSpace is aligned on an 8-byte boundary This happened on the pipeline’s ARM64 UI test machine. ## PR Checklist - [x] Closes: #41555 - [ ] **Communication:** I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected - [ ] **Tests:** Added/updated and all pass - [ ] **Localization:** All end-user-facing strings can be localized - [ ] **Dev docs:** Added/updated - [ ] **New binaries:** Added on the required places - [ ] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [ ] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [ ] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [ ] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: #xxx ## Detailed Description of the Pull Request / Additional comments ## Validation Steps Performed --- src/modules/MeasureTool/MeasureToolCore/ToolState.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/modules/MeasureTool/MeasureToolCore/ToolState.h b/src/modules/MeasureTool/MeasureToolCore/ToolState.h index 57d5d04ca1..6d046a43fe 100644 --- a/src/modules/MeasureTool/MeasureToolCore/ToolState.h +++ b/src/modules/MeasureTool/MeasureToolCore/ToolState.h @@ -31,7 +31,11 @@ struct CommonState Measurement::Unit units = Measurement::Unit::Pixel; - POINT cursorPosSystemSpace = {}; // updated atomically + #pragma warning(push) + #pragma warning(disable : 4324) + alignas(8) POINT cursorPosSystemSpace = {}; // updated atomically + #pragma warning(pop) + std::atomic_bool closeOnOtherMonitors = false; float GetPhysicalPx2MmRatio(HWND window) const