From 36487c15886dba229c295a9cb2fff6bea98ec1c5 Mon Sep 17 00:00:00 2001 From: Chris Burel Date: Thu, 10 Feb 2022 12:57:09 -0800 Subject: [PATCH] Fix alignment of `CONTEXT` variable The previous code had the `alignas()` in the wrong place, it needs to be left of the typename. Furthermore, `CONTEXT` has a default alignment of 16, so using `alignas(8)` underaligns. Signed-off-by: Chris Burel --- .../Platform/Windows/AzCore/Debug/StackTracer_Windows.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Code/Framework/AzCore/Platform/Windows/AzCore/Debug/StackTracer_Windows.cpp b/Code/Framework/AzCore/Platform/Windows/AzCore/Debug/StackTracer_Windows.cpp index a3f8b1e349..0d3cc7e032 100644 --- a/Code/Framework/AzCore/Platform/Windows/AzCore/Debug/StackTracer_Windows.cpp +++ b/Code/Framework/AzCore/Platform/Windows/AzCore/Debug/StackTracer_Windows.cpp @@ -1036,7 +1036,7 @@ cleanup: } HANDLE hThread = nativeThread; - CONTEXT alignas(8) context; // Without this alignment the function randomly crashes in release. + alignas(alignof(CONTEXT)) CONTEXT context; // Without this alignment the function randomly crashes in release. context.ContextFlags = CONTEXT_ALL; GetThreadContext(hThread, &context);