Skip to content

[HttpClient] Segfault with http2 server using push #37252

@mpesari

Description

@mpesari

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy