Bug 128727 (IT:45323)

Summary: python httplib.HTTPSConnection not thread safe
Product: Red Hat Enterprise Linux 3 Reporter: Brian Long <brilong>
Component: pythonAssignee: Mihai Ibanescu <mihai.ibanescu>
Status: CLOSED ERRATA QA Contact:
Severity: high Docs Contact:
Priority: medium    
Version: 3.0CC: jkeating, jneedle, katzj, tao
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-12-22 01:51:25 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 123574    
Attachments:
Description Flags
httplib.HTTPConnection script
none
httplib.HTTPSConnection script
none
backport ssl thread support from python 2.3.3 none

Description Brian Long 2004-07-28 18:48:14 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040204

Description of problem:
Simple threaded python script breaks when httplib.HTTPSConnection is
used.  httplib.HTTPConnection works fine in the same scenario.  It is
unclear if this is a httplib issue or a openssl bindings issue.

Version-Release number of selected component (if applicable):
python-2.2.3-5

How reproducible:
Always

Steps to Reproduce:
1. Start netcat "nc -l -p 8080".
2. Run python-https.py on same host.

    

Actual Results:  When httplib.HTTPConnection is called, "I'm still
here" prints on the screen every 2 seconds.  When
httplib.HTTPSConnection is called, "I'm still here" prints once and
then the script bombs (and the output on the netcat window is screwed up).

Expected Results:  When httplib.HTTPSConnection is called, "I'm still
here" should print every 2 seconds just like when using
httplib.HTTPConnection.

Additional info:

python 2.3 on Fedora Core 2 does NOT have this issue.  Whatever
changed in python 2.3 (or openssl) on FC2 should be back-ported to
RHEL 3 to fix this issue.

Comment 1 Brian Long 2004-07-28 18:49:43 UTC
Created attachment 102260 [details]
httplib.HTTPConnection script

This script works in conjunction with "nc -l -p 8080" using the HTTP protocol.

Comment 2 Brian Long 2004-07-28 18:51:02 UTC
Created attachment 102261 [details]
httplib.HTTPSConnection script

This script fails in conjunction with "nc -l -p 8080".	The only difference
between this script and python-http.py is the httplib.HTTPConnection was
changed to httplib.HTTPSConnection.

Comment 3 Steve Conklin 2004-08-02 20:29:54 UTC
tao

Comment 4 Mihai Ibanescu 2004-08-04 16:48:25 UTC
I'd be interested to see if this happens with rhnlib as well.
python's stock ssl implementation is pretty useless, that's why RHN
uses pyOpenSSL (binding directly to openssl). I'll modify the test
case for that.

Comment 8 Don Howard 2004-10-01 23:54:33 UTC
I've been looking at this ticket this afternoon, and I've noticed 
that the "I'm still here thread" appears to block on a futex after 
the network thread opens it's ssl connection.  In the non-ssl case, 
the "ISH" thread does not block on the futex.  The network thread 
appears to be doing the same number/order of futex wakes.  
 
I'm looking for the source (and backtrace) of the futex calls.. 

Comment 9 Don Howard 2004-10-05 05:43:51 UTC
Created attachment 104770 [details]
backport ssl thread support from python 2.3.3

Comment 10 Don Howard 2004-10-05 05:46:22 UTC
The above patch corrects the hang reported in this ticket. 
 
Needs review by someone who understands phython's threading/locking 
mechanisims. 

Comment 11 Mihai Ibanescu 2004-10-05 12:09:01 UTC
The patch looks harmless. Thanks for submitting it, I'll build a new
python package.

Comment 12 Brian Long 2004-10-06 00:54:54 UTC
Can you please release this RPM as an errata for RHEL 3?  If possible,
releasing it before Update 4 would be ideal; otherwise, please include
it in Update 4.  Thank you.

Comment 13 Steve Conklin 2004-10-26 19:28:59 UTC
Did this make the U4 beta?

Comment 14 Mihai Ibanescu 2004-10-26 19:55:55 UTC
No, looks like I missed the deadline. I'll build the packages
nevertheless and put them on people.redhat.com in the meantime.

Comment 15 Mihai Ibanescu 2004-10-26 22:06:01 UTC
Packages are now available at:
ftp://people.redhat.com/misa/python-fixes/mt-ssl/

The packages are signed with my GPG key, available at:
http://people.redhat.com/misa/misa.gpg

Comment 18 Brian Long 2004-10-27 12:46:33 UTC
It was my understanding from IBM Level 3 support that this package
would be in U4.  Is there any chance this package can be added to the
U4 beta in RHN so people can test it until U4 is GA?

Comment 19 Mihai Ibanescu 2004-10-27 14:07:16 UTC
Brian,

We are currently working with Release Engineering and QA on a plan to
put this package in U4. As far as I know U4 beta is frozen, but we
will see what we can do to make them widely available. In the
meantime, if you can try to run the packages posted on comment #15 in
one of your environments that are exhibiting the problem, that would
give me a higher level of confidence that the problem is indeed fixed.

Comment 20 Brian Long 2004-10-27 15:08:53 UTC
Mihai,

The problem is fixed with your RPM.  That's why I'm hoping it shows up
in U4  :)  Thanks!

/Brian/

Comment 21 Mihai Ibanescu 2004-10-28 20:56:30 UTC
Brian, it's great to hear that! Major problems raised by QA excluded,
it should make it in U4.

Comment 22 John Flanagan 2004-12-22 01:51:25 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2004-616.html


Comment 23 Ray Strode [halfline] 2005-05-10 18:08:25 UTC
*** Bug 121428 has been marked as a duplicate of this bug. ***