xref: /PHP-8.0/ext/curl/tests/bug76675.phpt (revision 50054459)
1--TEST--
2Bug #76675 (Segfault with H2 server push write/writeheader handlers)
3--XFAIL--
4http2.golang.org/serverpush is gone
5--SKIPIF--
6<?php
7include 'skipif.inc';
8if (getenv("SKIP_ONLINE_TESTS")) {
9    die("skip online test");
10}
11$curl_version = curl_version();
12if ($curl_version['version_number'] < 0x073d00) {
13    exit("skip: test may crash with curl < 7.61.0");
14}
15die("skip test is slow due to timeout, and XFAILs anyway");
16?>
17--FILE--
18<?php
19$transfers = 1;
20$callback = function($parent, $passed) use (&$transfers) {
21    curl_setopt($passed, CURLOPT_WRITEFUNCTION, function ($ch, $data) {
22        echo "Received ".strlen($data);
23        return strlen($data);
24    });
25    $transfers++;
26    return CURL_PUSH_OK;
27};
28$mh = curl_multi_init();
29curl_multi_setopt($mh, CURLMOPT_PIPELINING, CURLPIPE_MULTIPLEX);
30curl_multi_setopt($mh, CURLMOPT_PUSHFUNCTION, $callback);
31$ch = curl_init();
32curl_setopt($ch, CURLOPT_URL, 'https://http2.golang.org/serverpush');
33curl_setopt($ch, CURLOPT_HTTP_VERSION, 3);
34curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
35curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
36curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
37curl_multi_add_handle($mh, $ch);
38$active = null;
39do {
40    $status = curl_multi_exec($mh, $active);
41    do {
42        $info = curl_multi_info_read($mh);
43        if (false !== $info && $info['msg'] == CURLMSG_DONE) {
44            $handle = $info['handle'];
45            if ($handle !== null) {
46                $transfers--;
47                curl_multi_remove_handle($mh, $handle);
48                curl_close($handle);
49            }
50        }
51    } while ($info);
52} while ($transfers);
53curl_multi_close($mh);
54?>
55--EXPECTREGEX--
56(Received \d+)+
57