bug76675.phpt 1.6 KB

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