Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Musl
提交
0657ea0f
T
Third Party Musl
项目概览
OpenHarmony
/
Third Party Musl
1 年多 前同步成功
通知
37
Star
125
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Musl
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
0657ea0f
编写于
4月 28, 2022
作者:
O
openharmony_ci
提交者:
Gitee
4月 28, 2022
浏览文件
操作
浏览文件
下载
差异文件
!290 预留线程信号栈空间,避免无法捕获stackoverflow类型的崩溃
Merge pull request !290 from Maplestory_zeng/master
上级
d2af330f
5b34d1cf
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
59 addition
and
1 deletion
+59
-1
musl_template.gni
musl_template.gni
+2
-0
porting/linux/user/src/internal/pthread_impl.h
porting/linux/user/src/internal/pthread_impl.h
+3
-0
porting/linux/user/src/thread/pthread_create.c
porting/linux/user/src/thread/pthread_create.c
+54
-1
未找到文件。
musl_template.gni
浏览文件 @
0657ea0f
...
...
@@ -163,6 +163,8 @@ template("musl_libs") {
cflags_auto += [ "-DHOOK_ENABLE" ]
}
cflags_auto += [ "-DRESERVE_SIGNAL_STACK" ]
cflags_c99fse = [
"-std=c99",
"-nostdinc",
...
...
porting/linux/user/src/internal/pthread_impl.h
浏览文件 @
0657ea0f
...
...
@@ -48,6 +48,9 @@ struct pthread {
volatile
int
killlock
[
1
];
char
*
dlerror_buf
;
void
*
stdio_locks
;
#ifdef RESERVE_SIGNAL_STACK
void
*
signal_stack
;
#endif
/* Part 3 -- the positions of these fields relative to
* the end of the structure is external and internal ABI. */
...
...
porting/linux/user/src/thread/pthread_create.c
浏览文件 @
0657ea0f
...
...
@@ -5,10 +5,10 @@
#include "libc.h"
#include "lock.h"
#include <sys/mman.h>
#include <sys/prctl.h>
#include <string.h>
#include <stddef.h>
#include <stdarg.h>
#include <sys/prctl.h>
void
log_print
(
const
char
*
info
,...)
{
...
...
@@ -18,6 +18,50 @@ void log_print(const char* info,...)
va_end
(
ap
);
}
#ifdef RESERVE_SIGNAL_STACK
#if defined (__LF64__)
#define RESERVE_SIGNAL_STACK_SIZE (32 * 1024)
#else
#define RESERVE_SIGNAL_STACK_SIZE (20 * 1024)
#endif
static
void
__pthread_reserve_signal_stack
()
{
void
*
stack
=
mmap
(
NULL
,
RESERVE_SIGNAL_STACK_SIZE
,
PROT_READ
|
PROT_WRITE
,
MAP_PRIVATE
|
MAP_ANONYMOUS
,
-
1
,
0
);
if
(
stack
!=
MAP_FAILED
)
{
if
(
mprotect
(
stack
,
__default_guardsize
,
PROT_NONE
)
==
-
1
)
{
munmap
(
stack
,
RESERVE_SIGNAL_STACK_SIZE
);
return
;
}
}
stack_t
signal_stack
;
signal_stack
.
ss_sp
=
(
uint8_t
*
)
stack
+
__default_guardsize
;
signal_stack
.
ss_size
=
RESERVE_SIGNAL_STACK_SIZE
-
__default_guardsize
;
signal_stack
.
ss_flags
=
0
;
sigaltstack
(
&
signal_stack
,
NULL
);
pthread_t
self
=
__pthread_self
();
self
->
signal_stack
=
stack
;
prctl
(
PR_SET_VMA
,
PR_SET_VMA_ANON_NAME
,
signal_stack
.
ss_sp
,
signal_stack
.
ss_size
,
"signal_stack:musl"
);
return
;
}
static
void
__pthread_release_signal_stack
()
{
pthread_t
self
=
__pthread_self
();
if
(
self
->
signal_stack
==
NULL
)
{
return
;
}
stack_t
signal_stack
;
memset
(
&
signal_stack
,
0
,
sizeof
(
signal_stack
));
signal_stack
.
ss_flags
=
SS_DISABLE
;
sigaltstack
(
&
signal_stack
,
NULL
);
munmap
(
self
->
signal_stack
,
RESERVE_SIGNAL_STACK_SIZE
);
self
->
signal_stack
=
NULL
;
}
#endif
static
void
dummy_0
()
{
}
...
...
@@ -91,6 +135,9 @@ _Noreturn void __pthread_exit(void *result)
__block_app_sigs
(
&
set
);
__tl_lock
();
#ifdef RESERVE_SIGNAL_STACK
__pthread_release_signal_stack
();
#endif
/* If this is the only thread in the list, don't proceed with
* termination of the thread, but restore the previous lock and
* signal state to prepare for exit to call atexit handlers. */
...
...
@@ -200,12 +247,18 @@ static int start(void *p)
}
}
__syscall
(
SYS_rt_sigprocmask
,
SIG_SETMASK
,
&
args
->
sig_mask
,
0
,
_NSIG
/
8
);
#ifdef RESERVE_SIGNAL_STACK
__pthread_reserve_signal_stack
();
#endif
__pthread_exit
(
args
->
start_func
(
args
->
start_arg
));
return
0
;
}
static
int
start_c11
(
void
*
p
)
{
#ifdef RESERVE_SIGNAL_STACK
__pthread_reserve_signal_stack
();
#endif
struct
start_args
*
args
=
p
;
int
(
*
start
)(
void
*
)
=
(
int
(
*
)(
void
*
))
args
->
start_func
;
__pthread_exit
((
void
*
)(
uintptr_t
)
start
(
args
->
start_arg
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录