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

[v5.0.0-beta.1] Segmentation fault

bileslav opened this issue · comments

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
  • the exit code in that case is 139
  • sometimes several in a row, sometimes not one long enough - need to spam php segfault.php
  • not sure if it appears when using non-HTTP/2
  • tested with StreamSelectDriver and UvDriver - same result

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

@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.

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.

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

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.

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.

It seems that the issue has completely lost its relevance.