From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) by sourceware.org (Postfix) with ESMTPS id 02DE33858D39 for ; Tue, 12 Mar 2024 12:00:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 02DE33858D39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 02DE33858D39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710244807; cv=none; b=PHzE8kzz2V1q07ObJESYXrexFygmJHzYrUmNX8+lh4o/9bbqtlQuOs/j9hox+OGXJo4D+VPuimLF37CwcZbNCmODfhaYrGzR/SotqnCa1SSIY5RIJlXtOVhmhrHLdaXg0nUMd1k2maoJMji5YkbdoSIgnZ5FawITkXnqehiJo1A= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710244807; c=relaxed/simple; bh=jweFZRBu0N2zBkzqIwUeoX8DtqPMXDMsjYAYc9hs6CU=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=Cx1FkWbzKHSutH7wHeHhITazILrlCr1kcN6Pafm6e0s971UdI+nmcuVXjA5S7jF4sGZyzkdkRhoyOfR6fTvEZ2eBP8fq+26IHdV4LBMuQbPFPcQ5JCMWesWdTucTuwtcILoIqEnB40RQuhV112+S8XN2byHHr5RN+CiZXANawRo= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710244804; x=1741780804; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=jweFZRBu0N2zBkzqIwUeoX8DtqPMXDMsjYAYc9hs6CU=; b=ap/Ga9/CMCYJUwmkHRnZgP+lp7uqS3LNiE/sKDzqMFOYnUOw5zEqVk3+ dJzSYyvD5YtpRKh9mJPe58FqYLIZrbtdzTZmfOU8tCIRI3C/N9WABMkTX rp2Ixb06tWplQM8wu65ViwC7EAxPx7Hy43E4BgNf3vQetxpgudBBmAemm AoYpRn0gVPlfRfmlu+h2KWNk172BOY4qTwtUoY+FuctC9oBLK35tu6e+j kBESvmrU1MRsJZ2cq8qwdqPxtki9y6UDgUyt2rnTU/PkPFdCb+zWfqT94 67/ZVONQa6q1gUbA2+WmZF/v0+UDtET3vXfvq3Zl+rgQbDaLgvic1DHsl A==; X-IronPort-AV: E=McAfee;i="6600,9927,11010"; a="5554194" X-IronPort-AV: E=Sophos;i="6.07,119,1708416000"; d="scan'208";a="5554194" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Mar 2024 05:00:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,119,1708416000"; d="scan'208";a="16116067" Received: from shvmail03.sh.intel.com ([10.239.245.20]) by fmviesa004.fm.intel.com with ESMTP; 12 Mar 2024 05:00:00 -0700 Received: from shliclel4217.sh.intel.com (shliclel4217.sh.intel.com [10.239.240.127]) by shvmail03.sh.intel.com (Postfix) with ESMTP id A17E11005056; Tue, 12 Mar 2024 19:59:59 +0800 (CST) From: liuhongt To: gcc-patches@gcc.gnu.org Cc: crazylht@gmail.com, hjl.tools@gmail.com Subject: [PATCH] sanitizer: [PR110027] Align asan_vec[0] to MAX (alignb, ASAN_RED_ZONE_SIZE) Date: Tue, 12 Mar 2024 19:57:59 +0800 Message-Id: <20240312115759.4067084-1-hongtao.liu@intel.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: if alignb > ASAN_RED_ZONE_SIZE and offset[0] is not multiple of alignb. (base_align_bias - base_offset) may not aligned to alignb, and caused segement fault. Bootstrapped and regtested on x86_64-linux-gnu{-m32,}. Ok for trunk and backport to GCC13? gcc/ChangeLog: PR sanitizer/110027 * cfgexpand.cc (expand_stack_vars): Align frame offset to MAX (alignb, ASAN_RED_ZONE_SIZE). gcc/testsuite/ChangeLog: * g++.dg/asan/pr110027.C: New test. --- gcc/cfgexpand.cc | 2 +- gcc/testsuite/g++.dg/asan/pr110027.C | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/asan/pr110027.C diff --git a/gcc/cfgexpand.cc b/gcc/cfgexpand.cc index 0de299c62e3..92062378d8e 100644 --- a/gcc/cfgexpand.cc +++ b/gcc/cfgexpand.cc @@ -1214,7 +1214,7 @@ expand_stack_vars (bool (*pred) (size_t), class stack_vars_data *data) { if (data->asan_vec.is_empty ()) { - align_frame_offset (ASAN_RED_ZONE_SIZE); + align_frame_offset (MAX (alignb, ASAN_RED_ZONE_SIZE)); prev_offset = frame_offset.to_constant (); } prev_offset = align_base (prev_offset, diff --git a/gcc/testsuite/g++.dg/asan/pr110027.C b/gcc/testsuite/g++.dg/asan/pr110027.C new file mode 100644 index 00000000000..0067781bc89 --- /dev/null +++ b/gcc/testsuite/g++.dg/asan/pr110027.C @@ -0,0 +1,20 @@ +/* PR sanitizer/110027 */ +/* { dg-do run } */ +/* { dg-require-effective-target avx512f_runtime } */ +/* { dg-options "-std=gnu++23 -mavx512f -fsanitize=address -O0 -g -fstack-protector-strong" } */ + +#include +#include + +template +using Vec [[gnu::vector_size(W * sizeof(T))]] = T; + +auto foo() { + Vec<8, int64_t> ret{}; + return ret; +} + +int main() { + foo(); + return 0; +} -- 2.31.1