Closed
Description
Symfony version(s) affected: 5.1.1
Description
When using chaining HttpClient::create()->request(...)
on a server which does a http2 push, some kind of memory corruption occurs. This does not occur when calling request()
on an instantiated client: $client = HttpClient::create(); $client->request(...)
How to reproduce
Some tests and a Dockerfile for running them are available in my repo: https://github.com/mpesari/php-http2-push-issue
First, run composer require symfony/http-client
. Then, execute this file:
<?php
require_once __DIR__.'/vendor/autoload.php';
use Symfony\Component\HttpClient\HttpClient;
$http2PushUrl = 'https://http2.golang.org/serverpush';
$response = HttpClient::create()->request('GET', $http2PushUrl);
print strlen($response->getContent()) . PHP_EOL;
Output:
PHP Warning: Invalid callback , no array or string given in /root/vendor/symfony/http-client/Response/CurlResponse.php on line 264
PHP Warning: curl_multi_exec(): Cannot call the CURLMOPT_PUSHFUNCTION in /root/vendor/symfony/http-client/Response/CurlResponse.php on line 264
PHP Warning: Invalid callback , no array or string given in /root/vendor/symfony/http-client/Response/CurlResponse.php on line 264
PHP Warning: curl_multi_exec(): Cannot call the CURLMOPT_PUSHFUNCTION in /root/vendor/symfony/http-client/Response/CurlResponse.php on line 264
PHP Warning: Invalid callback , no array or string given in /root/vendor/symfony/http-client/Response/CurlResponse.php on line 264
PHP Warning: curl_multi_exec(): Cannot call the CURLMOPT_PUSHFUNCTION in /root/vendor/symfony/http-client/Response/CurlResponse.php on line 264
PHP Warning: Invalid callback , no array or string given in /root/vendor/symfony/http-client/Response/CurlResponse.php on line 264
PHP Warning: curl_multi_exec(): Cannot call the CURLMOPT_PUSHFUNCTION in /root/vendor/symfony/http-client/Response/CurlResponse.php on line 264
67507
double free or corruption (out)
Aborted (core dumped)
Possible Solution
Not exactly a solution, but maybe a hint to resolving this... First instantiating the client prevents the corruption from happening:
<?php
require_once __DIR__.'/vendor/autoload.php';
use Symfony\Component\HttpClient\HttpClient;
$http2PushUrl = 'https://http2.golang.org/serverpush';
$client = HttpClient::create();
$response = $client->request('GET', $http2PushUrl);
print strlen($response->getContent()) . PHP_EOL;
Additional context
This seems related to https://bugs.php.net/bug.php?id=77535