summaryrefslogtreecommitdiffstats
path: root/lib/libthr/thread/thr_private.h
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2015-01-03 18:38:46 +0000
committerkib <kib@FreeBSD.org>2015-01-03 18:38:46 +0000
commit8d1dfb4106d37750d526e6b8edca5945f8b0a4d5 (patch)
treee381919bf3f754392eb9a47b256135a1dbb2b2b1 /lib/libthr/thread/thr_private.h
parent7ac15f4b4cebad0f4e9d2094b6ea3fefa77ae568 (diff)
downloadFreeBSD-src-8d1dfb4106d37750d526e6b8edca5945f8b0a4d5.zip
FreeBSD-src-8d1dfb4106d37750d526e6b8edca5945f8b0a4d5.tar.gz
Fix known issues which blow up the process after dlopen("libthr.so")
(or loading a dso linked to libthr.so into process which was not linked against threading library). - Remove libthr interposers of the libc functions, including __error(). Instead, functions calls are indirected through the interposing table, similar to how pthread stubs in libc are already done. Libc by default points either to syscall trampolines or to existing libc implementations. On libthr load, libthr rewrites the pointers to the cancellable implementations already in libthr. The interposition table is separate from pthreads stubs indirection table to not pull pthreads stubs into static binaries. - Postpone the malloc(3) internal mutexes initialization until libthr is loaded. This avoids recursion between calloc(3) and static pthread_mutex_t initialization. - Reinstall signal handlers with wrapper on libthr load. The _rtld_is_dlopened(3) is used to avoid useless calls to sigaction(2) when libthr is statically referenced from the main binary. In the process, fix openat(2), swapcontext(2) and setcontext(2) interposing. The libc symbols were exported at different versions than libthr interposers. Export both libc and libthr versions from libc now, with default set to the higher version from libthr. Remove unused and disconnected swapcontext(3) userspace implementation from libc/gen. No objections from: deischen Tested by: pho, antoine (exp-run) (previous versions) Sponsored by: The FreeBSD Foundation MFC after: 1 week
Diffstat (limited to 'lib/libthr/thread/thr_private.h')
-rw-r--r--lib/libthr/thread/thr_private.h22
1 files changed, 20 insertions, 2 deletions
diff --git a/lib/libthr/thread/thr_private.h b/lib/libthr/thread/thr_private.h
index c6651cd..e8edbe1 100644
--- a/lib/libthr/thread/thr_private.h
+++ b/lib/libthr/thread/thr_private.h
@@ -763,7 +763,7 @@ void _thr_cancel_leave(struct pthread *, int) __hidden;
void _thr_testcancel(struct pthread *) __hidden;
void _thr_signal_block(struct pthread *) __hidden;
void _thr_signal_unblock(struct pthread *) __hidden;
-void _thr_signal_init(void) __hidden;
+void _thr_signal_init(int) __hidden;
void _thr_signal_deinit(void) __hidden;
int _thr_send_sig(struct pthread *, int sig) __hidden;
void _thr_list_init(void) __hidden;
@@ -839,7 +839,6 @@ int __sys_close(int);
int __sys_fork(void);
pid_t __sys_getpid(void);
ssize_t __sys_read(int, void *, size_t);
-ssize_t __sys_write(int, const void *, size_t);
void __sys_exit(int);
#endif
@@ -906,12 +905,31 @@ int _sleepq_remove(struct sleepqueue *, struct pthread *) __hidden;
void _sleepq_drop(struct sleepqueue *,
void (*cb)(struct pthread *, void *arg), void *) __hidden;
+int _pthread_mutex_init_calloc_cb(pthread_mutex_t *mutex,
+ void *(calloc_cb)(size_t, size_t));
+
struct dl_phdr_info;
void __pthread_cxa_finalize(struct dl_phdr_info *phdr_info);
void _thr_tsd_unload(struct dl_phdr_info *phdr_info) __hidden;
void _thr_sigact_unload(struct dl_phdr_info *phdr_info) __hidden;
void _thr_stack_fix_protection(struct pthread *thrd);
+int *__error_threaded(void);
+void __thr_interpose_libc(void) __hidden;
+pid_t __thr_fork(void);
+int __thr_pause(void) __hidden;
+int __thr_raise(int sig);
+int __thr_setcontext(const ucontext_t *ucp);
+int __thr_sigaction(int sig, const struct sigaction *act,
+ struct sigaction *oact) __hidden;
+int __thr_sigprocmask(int how, const sigset_t *set, sigset_t *oset);
+int __thr_sigsuspend(const sigset_t * set);
+int __thr_sigtimedwait(const sigset_t *set, siginfo_t *info,
+ const struct timespec * timeout);
+int __thr_sigwait(const sigset_t *set, int *sig);
+int __thr_sigwaitinfo(const sigset_t *set, siginfo_t *info);
+int __thr_swapcontext(ucontext_t *oucp, const ucontext_t *ucp);
+
__END_DECLS
#endif /* !_THR_PRIVATE_H */
OpenPOWER on IntegriCloud