amphp / http-client

An advanced async HTTP client library for PHP, enabling efficient, non-blocking, and concurrent requests and responses.
https://amphp.org/http-client
MIT License
704 stars 66 forks source link

[v5.0.0-beta.1] Segmentation fault #303

Closed bileslav closed 2 years ago

bileslav commented 2 years ago
subroot@BH:~/racoon-2/test$ php -v
PHP 8.1.5 (cli) (built: Apr 22 2022 04:56:05) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.5, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.5, Copyright (c), by Zend Technologies
// segfault.php

ini_set('error_reporting', E_ALL);
ini_set('error_log', null);

require 'vendor/autoload.php';

$client = Amp\Http\Client\HttpClientBuilder::buildDefault();
$request = new Amp\Http\Client\Request('https://www.youtube.com/watch?v=Yw6u6YkTgQ4');

for ($i = 0; $i < 10; $i++) {
    if ($client->request($request)->getStatus() !== 200) {
        throw new LogicException();
    }

    echo $i, ' ';
}

echo "\n";

Here's an output of the "successful" test:

subroot@BH:~/racoon-2/test$ php segfault.php
0 1 2 3 4 5 6 7 8 9 
Segmentation fault
trowski commented 2 years ago

I can't reproduce this with the below versions. Any other info you can give me?

PHP 8.1.7-dev (cli) (built: Apr 28 2022 18:50:42) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.7-dev, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.7-dev, Copyright (c), by Zend Technologies
bileslav commented 2 years ago

@trowski, I compiled the 8.1.7-dev on the same machine and ran the test one after the other. It seems that there really is no such problem there. Tomorrow I'll compile 8.1.5 on another machine and try it there, write back about the result.

bileslav commented 2 years ago

On the another machine:

[home ~]# php -v
PHP 8.1.5 (cli) (built: Apr 30 2022 15:23:16) (NTS DEBUG)
Copyright (c) The PHP Group
Zend Engine v4.1.5, Copyright (c) Zend Technologies

Here I also cannot reproduce the segfault.

I have no idea what's wrong with my build. It's obvious that the problem is not in the library, so I close the issue.

kelunik commented 2 years ago

@bileslaw Maybe we can still help, what's the output of php -m?

bileslav commented 2 years ago

@kelunik, php -m php -i

kelunik commented 2 years ago

The most likely extensions to make a difference are ffi, uv and opcache. Try disabling them one by one and see whether the segfault still happens.

bileslav commented 2 years ago

I'm afraid I can't reproduce this anymore, even without the suggested changes... Let's leave this for now. I'll come back here if the problem re-occurs.

bileslav commented 2 years ago

It seems that the issue has completely lost its relevance.