This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v2] Also use l_tls_dtor_count to decide on object unload (BZ #18657)
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: Siddhesh Poyarekar <siddhesh at redhat dot com>
- Cc: libc-alpha at sourceware dot org, roland at hack dot frob dot com
- Date: Fri, 10 Jul 2015 21:33:52 +0200
- Subject: Re: [PATCH v2] Also use l_tls_dtor_count to decide on object unload (BZ #18657)
- Authentication-results: sourceware.org; auth=none
- References: <20150709204301 dot 792A02C39DC at topped-with-meat dot com> <1436552195-16464-1-git-send-email-siddhesh at redhat dot com>
On Fri, Jul 10, 2015 at 11:46:35PM +0530, Siddhesh Poyarekar wrote:
> When an TLS destructor is registered, we set the DF_1_NODELETE flag to
> signal that the object should not be destroyed. We then clear the
> DF_1_NODELETE flag when all destructors are called, which is wrong -
> the flag could have been set by other means too.
>
> This patch replaces this use of the flag by using l_tls_dtor_count
> directly to determine whether it is safe to unload the object. This
> change has the added advantage of eliminating the lock taking when
> calling the destructors, which could result in a deadlock. The patch
> also fixes the test case tst-tls-atexit - it was making an invalid
> dlclose call, which would just return an error silently.
>
> Change verified on x86_64; the test suite does not show any
> regressions due to the patch.
>
Does not work. In thread A we register destructor just before atomic
add. Meanwhile we call dlclose in thread B which succeeds as count is
zero. After thread A resumes it causes SIGSEGV when destructor gets
called.