Date: Sun, 19 Sep 2010 05:19:47 +0000 (UTC) From: David Xu <davidxu@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r212837 - head/lib/libthr/thread Message-ID: <201009190519.o8J5JlOx090109@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: davidxu Date: Sun Sep 19 05:19:47 2010 New Revision: 212837 URL: http://svn.freebsd.org/changeset/base/212837 Log: Fix a race condition when finding stack unwinding functions. Modified: head/lib/libthr/thread/thr_exit.c Modified: head/lib/libthr/thread/thr_exit.c ============================================================================== --- head/lib/libthr/thread/thr_exit.c Sun Sep 19 02:07:30 2010 (r212836) +++ head/lib/libthr/thread/thr_exit.c Sun Sep 19 05:19:47 2010 (r212837) @@ -70,18 +70,31 @@ static void thread_uw_init(void) { static int inited = 0; + Dl_info dlinfo; void *handle; + void *forcedunwind, *resume, *getcfa; if (inited) - return; - inited = 1; + return; handle = RTLD_DEFAULT; - if ((uwl_forcedunwind = dlsym(handle, "_Unwind_ForcedUnwind")) == NULL|| - (uwl_resume = dlsym(handle, "_Unwind_Resume")) == NULL || - (uwl_getcfa = dlsym(handle, "_Unwind_GetCFA")) == NULL) { - uwl_forcedunwind = NULL; - return; + if ((forcedunwind = dlsym(handle, "_Unwind_ForcedUnwind")) != NULL) { + if (dladdr(forcedunwind, &dlinfo)) { + if ((handle = dlopen(dlinfo.dli_fname, RTLD_LAZY)) != NULL) { + forcedunwind = dlsym(handle, "_Unwind_ForcedUnwind"); + resume = dlsym(handle, "_Unwind_Resume"); + getcfa = dlsym(handle, "_Unwind_GetCFA"); + if (forcedunwind != NULL && resume != NULL && + getcfa != NULL) { + uwl_forcedunwind = forcedunwind; + uwl_resume = resume; + uwl_getcfa = getcfa; + } else { + dlclose(handle); + } + } + } } + inited = 1; } void
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201009190519.o8J5JlOx090109>