|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67965 Regression: stream_select blocks when using tls
Submitted: 2014-09-05 10:28 UTC Modified: 2014-09-09 16:37 UTC
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: arjen at react dot com Assigned: rdlowrey (profile)
Status: Closed Package: Streams related
PHP Version: 5.5Git-2014-09-05 (Git) OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: arjen at react dot com
New email:
PHP Version: OS:


 [2014-09-05 10:28 UTC] arjen at react dot com
stream_select blocks if there is still data in the read buffer which you haven't read yet..

Testscripts reads 8096 bytes (default chunksize) but there's already more to read. We expect stream_select to return $read again but it won't.

This works fine in 5.5.16 and previous versions.

Broken by

Btw, tested using PHP5.5.16RC1 from

Test script:

$host = 'tcp://';
$chunkSize = 8192;

$fp = stream_socket_client($host, $errNumber, $errString, 5, STREAM_CLIENT_CONNECT);

stream_socket_enable_crypto($fp, true, STREAM_CRYPTO_METHOD_TLS_CLIENT);

$data = "GET / HTTP/1.1\r\nConnection: close\r\nHost:\r\n\r\n";

fwrite($fp, $data);

while (!feof($fp))
	$read = array($fp);
	$except = $write = null;

	$changed = stream_select($read, $write, $except, 5, 0);

	if (!empty($read))
		$read = fread($fp, $chunkSize);
		echo 'read ' . strlen($read) . PHP_EOL;

Expected result:
read 8192
read 8192
read 8192
read 5961

Actual result:
read 8192
read 8192

and script hangs..


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2014-09-09 16:37 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: rdlowrey
 [2014-09-09 16:37 UTC]
This should be fixed in commit f86b2193a:

Thanks for the report. If your issues persist (hopefully the won't) please update this issue :)
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 20 00:01:31 2024 UTC