This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug nptl/21069] printf may deadlock when threads get cancled
- From: "ma.jiang at zte dot com.cn" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Fri, 20 Jan 2017 02:43:53 +0000
- Subject: [Bug nptl/21069] printf may deadlock when threads get cancled
- Auto-submitted: auto-generated
- References: <bug-21069-131@http.sourceware.org/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=21069
ma.jiang at zte dot com.cn changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ma.jiang at zte dot com.cn
--- Comment #2 from ma.jiang at zte dot com.cn ---
(In reply to ma.jiang from comment #0)
> Created attachment 9764 [details]
> test case to reproduce the bug
>
> Hi all,
> I found a bug may cause deadlock still existed in the latest glibc source.
> For a static binary, when a thread which is going through the printf
> function get cancled, the stream lock will not be unlocked.
> In ./sysdeps/nptl/libc-lockP.h, _pthread_cleanup_push_defer were declared
> to be a weakref. So, in macro __libc_cleanup_region_start(in
> sysdeps/nptl/libc-lock.h), after "_avail = PTFAVAIL
> (_pthread_cleanup_push_defer);", _avail will turn out to be 0 as there are
> no strong references for _pthread_cleanup_push_defer.
> This bug can be reproduce by the attached file(I have tested it under
> glibc-2.24 x86-64).
This bug is easy to fix, just two PTHREAD_STATIC_FN_REQUIRE in pthread_create.c
will be enough. See the attached patch.
By the way, guys using glibc from redhat(or other distributions) probably can
not reproduce the bug. Packaged maintainers re-linked all objects from
libpthread.a(using ld -r) into a single object file, and rebuild the
libpthread.a from that object. So , _pthread_cleanup_push_defer will always
exist in the final binary, and of course the bug will not be reproducible
then.
--
You are receiving this mail because:
You are on the CC list for the bug.