amphp / http-client

An advanced async HTTP client library for PHP, enabling efficient, non-blocking, and concurrent requests and responses.

Home Page:https://amphp.org/http-client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

unexpected segmentation fault

azjezz opened this issue · comments

Haven't dug up what the issue is, however, currently, the segmentation fault occurs for fruitz.io, but not any other URLs that i have tried.

code to reproduce:

<?php

namespace Bumble;

use Amp\Http\Client\Connection\UnlimitedConnectionPool;
use Amp\Http\Client\HttpClient;
use Amp\Http\Client\PooledHttpClient;
use Amp\Http\Client\Request;
use Psl\IO;

require __DIR__ . '/../vendor/autoload.php';

$pool = new UnlimitedConnectionPool();
$delegate = new PooledHttpClient($pool);
$client = new HttpClient($delegate);

// OKAY!
$request = new Request('https://bumble.com/', 'GET');
$client->request($request);

// SEGMENTATION FAULT!
$request = new Request('https://fruitz.io/', 'GET');
$client->request($request);

composer.json:

{
    "name": "bumble/experiments",
    "require": {
        "php": "^8.2",
        "azjezz/psl": "^2.5",
        "amphp/amp": "^3.0",
        "amphp/http": "v2.0.0-beta.1",
        "amphp/postgres": "v2.0.0-beta.2",
        "amphp/http-client": "v5.0.0-beta.8"
    },
    "autoload": {
        "psr-4": {
            "Bumble\\": "src/"
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}

Make sure you're using either php 8.1.17+ or 8.2.4+, older versions have some nasty fiber bugs that prevent any async applications from running properly.

More specifically, 8.1.15-16 and 8.2.2-3 have a GC bug that will segfault in a fiber, which was fixed in 8.1.17 and 8.2.4.

I was considering throwing an exception or triggering an error in the Revolt event loop if the affected versions are used since the application will segfault eventually.

Also, all versions pre-8.1.17 and pre-8.2.4 have some another, rarer fiber bug that might be triggered a segfault a shutdown handler, so it's best to just use 8.1.17+ and 8.2.4+ :)

Thanks! seems to be working fine with 8.2.4 :D