Skip to content

Commit 768b949

Browse files
committed
[Backtracing][Linux] Properly align the stacks.
We have two stacks that we set up during crash handling, both of which were potentially misaligned. This only tripped us up on Ubuntu 20.04 on aarch64 - my guess is that maybe `clone()` aligns the stack pointer on newer kernels which is why we didn't see it on 22.04. rdar://110743884
1 parent a9df9e6 commit 768b949

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

stdlib/public/runtime/Backtrace.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ struct spawn_info {
796796
int memserver;
797797
};
798798

799-
uint8_t spawn_stack[4096];
799+
uint8_t spawn_stack[4096] __attribute__((aligned(SWIFT_PAGE_SIZE)));
800800

801801
int
802802
do_spawn(void *ptr) {

stdlib/public/runtime/CrashHandlerLinux.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ wait_paused(uint32_t expected, const struct timespec *timeout)
607607
We don't want to require CAP_SYS_PTRACE because we're potentially being
608608
used inside of a Docker container, which won't have that enabled. */
609609

610-
char memserver_stack[4096];
610+
char memserver_stack[4096] __attribute__((aligned(SWIFT_PAGE_SIZE)));
611611
char memserver_buffer[4096];
612612
int memserver_fd;
613613
bool memserver_has_ptrace;

0 commit comments

Comments
 (0)