From 3d40192d3d7e80dc2ba0283cf11575eab96b808f Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Mon, 10 Aug 2015 17:02:42 +0000 Subject: [PATCH] Pre-resolve symbols required for the deferred signal processing. This avoids recursion into rtld when leaving libthr critical section for the deferred signal delivery. For the same reason, use syscall(2) instead of referencing __sys_sigreturn(2). Syscall() is already pre-resolved for fork() interceptor. Tested by: Andre Meiser Sponsored by: The FreeBSD Foundation MFC after: 1 week --- lib/libthr/thread/thr_rtld.c | 7 +++++++ lib/libthr/thread/thr_sig.c | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/libthr/thread/thr_rtld.c b/lib/libthr/thread/thr_rtld.c index 5d899880d1c5..cb200980cb26 100644 --- a/lib/libthr/thread/thr_rtld.c +++ b/lib/libthr/thread/thr_rtld.c @@ -185,7 +185,9 @@ _thr_rtld_init(void) { struct RtldLockInfo li; struct pthread *curthread; + ucontext_t *uc; long dummy = -1; + int uc_len; curthread = _get_curthread(); @@ -231,4 +233,9 @@ _thr_rtld_init(void) _thr_signal_block(curthread); _rtld_thread_init(&li); _thr_signal_unblock(curthread); + + uc_len = __getcontextx_size(); + uc = alloca(uc_len); + getcontext(uc); + __fillcontextx2((char *)uc); } diff --git a/lib/libthr/thread/thr_sig.c b/lib/libthr/thread/thr_sig.c index a6d021fed31d..ebb6c58a4bb6 100644 --- a/lib/libthr/thread/thr_sig.c +++ b/lib/libthr/thread/thr_sig.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -257,7 +258,7 @@ handle_signal(struct sigaction *actp, int sig, siginfo_t *info, ucontext_t *ucp) /* reschedule cancellation */ check_cancel(curthread, &uc2); errno = err; - __sys_sigreturn(&uc2); + syscall(SYS_sigreturn, &uc2); } void