RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1405071 - getaddrinfo looses internal lock with deferred cancellation.
Summary: getaddrinfo looses internal lock with deferred cancellation.
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: glibc
Version: 7.0
Hardware: x86_64
OS: Linux
unspecified
unspecified
Target Milestone: pre-dev-freeze
: ---
Assignee: glibc team
QA Contact: qe-baseos-tools-bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-12-15 14:09 UTC by Keyue Hu
Modified: 2019-06-18 19:34 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-06-18 19:34:34 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
backtrace of deadlock (17.83 KB, text/plain)
2016-12-15 14:09 UTC, Keyue Hu
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Sourceware 20975 0 P2 NEW Deferred cancellation triggers in __check_pf and looses lock leading to deadlock. 2020-06-05 12:43:52 UTC

Description Keyue Hu 2016-12-15 14:09:45 UTC
Created attachment 1232178 [details]
backtrace of deadlock

Description of problem:
when pthread_cancel() on the thread calling getaddrinfo(), the libc lock in check_pf.c might be left without being unlocked. and then the next getaddrinfo call hangs forever. 


Version-Release number of selected component (if applicable):
glibc-2.17-106.el7_2.8.x86_64


How reproducible:
easy to reproduce.

Steps to Reproduce:
1. start thread calling zookeeper_init on 127.0.0.1 which calls getaddrinfo
2. call pthread_cancel on this thread
3. repeat 1-2

Actual results:
get hanged on getaddrinfo

Expected results:
never hangs


Additional info:
[root@3b3cfab6b378 /]# uname -a
Linux 3b3cfab6b378 3.10.0-327.36.3.el7.x86_64 #1 SMP Mon Oct 24 16:09:20 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
[root@3b3cfab6b378 /]# rpm -q glibc
glibc-2.17-106.el7_2.8.x86_64

Comment 1 Keyue Hu 2016-12-15 14:14:48 UTC
in the source code of glibc, sysdeps/unix/sysv/linux/check_pf.c 

between L322-L356, there are pthread cancellation point in __socket, __bind, or make_request. If we get pthread_cancel, when code goes in L322-L356 the check_pf lock is left locked. 

by the way the upstream glibc seems has no such issue.

Comment 2 Keyue Hu 2016-12-15 14:36:34 UTC
to be correct, the upstream might have the same issue.

Comment 3 Carlos O'Donell 2016-12-16 01:50:12 UTC
There are no cancellation points in __socket or __bind.

Cancellation points in those functions would violate the POSIX requirements that no additional cancellation points be present other than those here:
 2.9.5 Thread Cancellation
http://pubs.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_09.html
"An implementation shall not introduce cancellation points into any other functions specified in this volume of IEEE Std 1003.1-2001."

However, in make_request, there is a __sendto, __recvmsg, and__netlink_assert_response, all of which could be cancellable and that would cause the lock to be lost and the subsequent __check_pf to hang.

There is a _lot_ of code running in make_request, the simplest solution is to push a cleanup handler to unlock the lock.

I've filed an upstream bug for this.
https://sourceware.org/bugzilla/show_bug.cgi?id=20975

Thanks for the bug report.

Comment 4 Keyue Hu 2016-12-16 02:36:23 UTC
Yeah, only __sendto and __recvmsg are cancellable. 

and it is kind of you to fillup upstream bug. thanks!

Comment 6 Carlos O'Donell 2019-06-18 19:34:34 UTC
Red Hat Enterprise Linux 7 is entering Maintenance Phase Support 1 this year and as such this issue will not be considered for fixing in RHEL 7 and is being closed. If you still encounter this issue with Red Hat Enterprise Linux 8, then please open a new issue with such details. Note that the upstream issue will remain for upstream tracking.


Note You need to log in before you can comment on or make changes to this bug.