From e91ff25c0c0b2bd0d7d8bd5b1c96457bf2bef352 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Tue, 6 May 2008 09:27:41 +0000 Subject: Fix the problem with the C++ exception handling for the multithreaded programs. From the PR description: The gcc runtime's _Unwind_Find_FDE function, invoked during exception handling's stack unwinding, is not safe to execute from within multiple threads. FreeBSD' s dl_iterate_phdr() however permits multiple threads to pass through it though. The result is surprisingly reliable infinite looping of one or more threads if they just happen to be unwinding at the same time. Introduce the new lock that is write locked around the dl_iterate_pdr, thus providing required exclusion for the stack unwinders. PR: threads/123062 Submitted by: Andy Newman Reviewed by: kan MFC after: 2 weeks --- libexec/rtld-elf/rtld_lock.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'libexec/rtld-elf/rtld_lock.c') diff --git a/libexec/rtld-elf/rtld_lock.c b/libexec/rtld-elf/rtld_lock.c index 1d77fe105591..c67f5fb0d545 100644 --- a/libexec/rtld-elf/rtld_lock.c +++ b/libexec/rtld-elf/rtld_lock.c @@ -171,7 +171,7 @@ thread_mask_clear(int mask) lockinfo.thread_clr_flag(mask); } -#define RTLD_LOCK_CNT 2 +#define RTLD_LOCK_CNT 3 struct rtld_lock { void *handle; int mask; @@ -179,6 +179,7 @@ struct rtld_lock { rtld_lock_t rtld_bind_lock = &rtld_locks[0]; rtld_lock_t rtld_libc_lock = &rtld_locks[1]; +rtld_lock_t rtld_phdr_lock = &rtld_locks[2]; int rlock_acquire(rtld_lock_t lock) -- cgit v1.3