1 Star 0 Fork 25

dpd/gperftools

forked from src-openEuler/gperftools 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
issue-1122-fix-bus-error-on-aarch64.patch 1.64 KB
一键复制 编辑 原始数据 按行查看 历史
hexiaowen 提交于 2019-09-30 10:51 . Package init
From 42dbe9e2ced74ae7f0f3b70daabf634edf44d3d3 Mon Sep 17 00:00:00 2001
From: Zhipeng Xie <xiezhipeng1@huawei.com>
Date: Thu, 13 Jun 2019 23:16:43 +0800
Subject: [PATCH] issue-1122: fix bus error on aarch64
According to the ARMv8 Instruction Set Overview, among other documents,
"... if SP is used as the base register then the value of the stack
pointer prior to adding any offset must be quadword (16 byte) aligned,
or else a stack alignment exception will be generated.". So, we pass
the child_stack 16 byte aligned to sys_clone.
Signed-off-by: Zhipeng Xie <xiezhipeng1@huawei.com>
---
src/base/linuxthreads.cc | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/base/linuxthreads.cc b/src/base/linuxthreads.cc
index 891e70c..00b1ea3 100644
--- a/src/base/linuxthreads.cc
+++ b/src/base/linuxthreads.cc
@@ -105,6 +105,7 @@ static int local_clone (int (*fn)(void *), void *arg, ...)
#define CLONE_STACK_SIZE 4096
#endif
+#define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))
static int local_clone (int (*fn)(void *), void *arg, ...) {
/* Leave 4kB of gap between the callers stack and the new clone. This
* should be more than sufficient for the caller to call waitpid() until
@@ -120,7 +121,9 @@ static int local_clone (int (*fn)(void *), void *arg, ...) {
* is being debugged. This is OK and the error code will be reported
* correctly.
*/
- return sys_clone(fn, (char *)&arg - CLONE_STACK_SIZE,
+ void *child_stack = (void *)ALIGN(((unsigned long)&arg - CLONE_STACK_SIZE),
+ 16);
+ return sys_clone(fn, child_stack,
CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_UNTRACED, arg, 0, 0, 0);
}
--
1.7.12.4
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/dpdwaj/gperftools.git
git@gitee.com:dpdwaj/gperftools.git
dpdwaj
gperftools
gperftools
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385