From 8a1f72b6fbc9fa52aa9d925b4b6c71524264e61f Mon Sep 17 00:00:00 2001
From: Ilya Verbin <iverbin@tarantool.org>
Date: Wed, 16 Oct 2024 16:34:26 +0300
Subject: [PATCH] box: fix SIGSEGV on unaligned access to `struct applier`

All structures with a non-default alignment (set by `alignas()`) must be
allocated by `aligned_alloc()`, otherwise an access to such a structure
member fill crash, e.g. if compiled with AVX-512 support.

See also commit a60ec82d4f07 ("box: fix SIGSEGV on unaligned access to a
struct with extended alignment").

Closes #10699

NO_DOC=bugfix
NO_CHANGELOG=minor
NO_TEST=tested by debug_asan_clang workflow

(cherry picked from commit bf091358806ed17bf44efd2cf382a43c0ba49fe0)
---
 src/box/applier.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/box/applier.cc b/src/box/applier.cc
index 1132081826..01642beac5 100644
--- a/src/box/applier.cc
+++ b/src/box/applier.cc
@@ -2696,8 +2696,8 @@ applier_stop(struct applier *applier)
 struct applier *
 applier_new(struct uri *uri)
 {
-	struct applier *applier = (struct applier *)
-		xcalloc(1, sizeof(struct applier));
+	struct applier *applier = xalloc_object(struct applier);
+	memset(applier, 0, sizeof(*applier));
 	if (iostream_ctx_create(&applier->io_ctx, IOSTREAM_CLIENT, uri) != 0) {
 		free(applier);
 		diag_raise();
-- 
GitLab