This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug nptl/21069] printf may deadlock when threads get cancled

ma.jiang at zte dot changed:

           What    |Removed                     |Added
                 CC|                            |ma.jiang at zte dot

--- Comment #2 from ma.jiang at zte dot ---
(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

You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]