[php-src] PR #25911: CI: Fix intermittent curl test failures on FreeBSD
| From: | jorgsowa | Date: | Sun, 29 Nov 2026 23:18:28 +0000 |
| Subject: | [php-src] PR #25911: CI: Fix intermittent curl test failures on FreeBSD | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-41219@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/25911
Author: jorgsowa
ext/curl/tests/server.inc starts the dev server on localhost:0. FreeBSD
resolves localhost to 127.0.0.1 first, so the server listens on 127.0.0.1 only. libcurl
resolves localhost itself and tries [::1] first. Nothing listens on
[::1]:port, so the kernel sometimes picks that same port as the local port of the
outgoing connection, and the socket connects to itself. curl then reads back its own request and
fails with "Received HTTP/0.9 when not allowed", so curl_exec() returns
false.
Binding to 127.0.0.1 avoids the ::1 connection attempt entirely. FreeBSD won't
hand out a port as a local port while a listener owns it on the same address, so an IPv4 connection
can't connect to itself while the server is running.
Recent FreeBSD failures:
- [curl_basic_003.phpt](https://github.com/php/php-src/actions/runs/46277082137/job/141390691996)
- [curl_basic_006.phpt](https://github.com/php/php-src/actions/runs/46091929128/job/140814814152)
-
[curl_setopt_CURLOPT_DEBUGFUNCTION.phpt](https://github.com/php/php-src/actions/runs/45303330074/job/138141504255)
-
[curl_string_file_upload.phpt](https://github.com/php/php-src/actions/runs/44198651652/job/134446785578)
Tested on FreeBSD 14.4:
- [Default port range](https://github.com/jorgsowa/php-src/actions/runs/46300860477): 4
self-connects in 156,033 requests with localhost, none in 156,006 with 127.0.0.1.
- [Local port range narrowed to 100
ports](https://github.com/jorgsowa/php-src/actions/runs/46319602819): 137 self-connects in 12,879
requests with localhost, none in 12,879 with 127.0.0.1. ext/curl tests
failed in 5/5 rounds without the fix and passed 10/10 with it, plus 10/10 at the default range.