提交 cae2c5d6 编写于 作者: F fangting

fix "exit" in global constructor causes the program to hang

commit 188759bb documented the intent
to allow recursive dlopen based on tracking ctor_visitor, but used a
kernel tid rather than the pthread_t to identify the caller. as a
result, it would not behave as intended under fork by a ctor, where
the child tid would not match.

Test:libc-test/src/function/exit.c
Issue:I7F2LR
Signed-off-by: Nfangting <fangting12@huawei.com>
上级 e932e671
#include <stdlib.h>
#include "test.h"
__attribute__((constructor))
void B_ctor() {
exit(t_status);
}
int main() {
return t_status;
}
\ No newline at end of file
......@@ -80,6 +80,7 @@ functional_list = [
"wcstol",
"dlclose_reset",
"atexit_dlclose",
"exit_constructor",
]
if (use_pthread_cancel) {
......
......@@ -2508,7 +2508,7 @@ static void do_init_fini(struct dso **queue)
{
struct dso *p;
size_t dyn[DYN_CNT], i;
int self = __pthread_self()->tid;
pthread_t self = __pthread_self();
pthread_mutex_lock(&init_fini_lock);
for (i=0; (p=queue[i]); i++) {
......
......@@ -106,7 +106,7 @@ struct dso {
dev_t dev;
ino_t ino;
uint64_t file_offset;
int ctor_visitor;
pthread_t ctor_visitor;
char *rpath_orig, *rpath;
struct tls_module tls;
size_t tls_id;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册