php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50866 stream_socket_enable_crypto() hangs for unnegotiable SSL connections for socket
Submitted: 2010-01-27 22:14 UTC Modified: 2013-02-18 00:34 UTC
From: nj506 at zepler dot net Assigned:
Status: No Feedback Package: Streams related
PHP Version: 5.3.1 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
44 - 4 = ?
Subscribe to this entry?

 
 [2010-01-27 22:14 UTC] nj506 at zepler dot net
Description:
------------
stream_socket_enable_crypto() hangs for unnegotiable SSL connections for sockets connected in asynchronous mode.

Whilst I'm not greatly familiar with the PHP source, I believe it is caused by the following line of code in xp_ssl.c:

timeout -= (tve.tv_sec + (float) tve.tv_usec / 1000000) - (tvs.tv_sec + (float) tvs.tv_usec / 1000000);

I'm often seeing no difference in tve.tv_sec and tvs.tv_sec, and the difference between tve.tv_usec and tvs.tv_usec is typically 4/5 microseconds for the particular scenario I've been debugging. 4/1000000 deduction from the timeout float results in essentially no change. Therefore the code loops for a very long time. In anycase, a printf on the timeout float see's no change after running for a good length of time.

Note: I don't believe this is the same issue as #45808, since this affects client connections, not server connections [+ the area of code I believe to be guilty is specific to client connections]

I'd also note that stream_set_blocking appears to have no effect on this area of code - but I'm not sure if thats a bug or not.

Reproduce code:
---------------
<?PHP

// The given address should not be connectable..

$socket = stream_socket_client("tcp://{$address}", $errno, $errstr, 15, STREAM_CLIENT_CONNECT|STREAM_CLIENT_ASYNC_CONNECT);
var_dump(stream_socket_enable_crypto($socket, true, STREAM_CRYPTO_METHOD_SSLv23_CLIENT));

?>

Expected result:
----------------
0/false [after "timeout" seconds]

Actual result:
--------------
Hangs pretty much forever.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-01-28 08:37 UTC] jani@php.net
Please try using this snapshot:

  http://snaps.php.net/php5.3-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2010-02-05 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2010-04-25 20:24 UTC] felipe@php.net
-Status: No Feedback +Status: Feedback
 [2010-04-25 20:24 UTC] felipe@php.net
Please try using this snapshot:

  http://snaps.php.net/php5.3-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2013-02-18 00:34 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 07:01:27 2024 UTC