Skip to content

ext/sockets: run the AF_PACKET error test in isolation - #22773

Merged
iliaal merged 1 commit into
php:masterfrom
iliaal:fix/afpacket-test-parallel-unsafe
Jul 17, 2026
Merged

ext/sockets: run the AF_PACKET error test in isolation#22773
iliaal merged 1 commit into
php:masterfrom
iliaal:fix/afpacket-test-parallel-unsafe

Conversation

@iliaal

@iliaal iliaal commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

The no-data case does this:

$s = socket_create(AF_PACKET, SOCK_RAW, ETH_P_ALL);
socket_bind($s, 'lo');
socket_set_nonblock($s);
$ret = @socket_recvfrom($s, $buf, 65536, 0, $addr);
var_dump($ret === false);   // asserts nothing is on lo

An ETH_P_ALL socket bound to lo captures every loopback frame, so that assertion holds only while no other test talks to localhost. run-tests spawns workers in parallel and the job runs as root (the SKIPIF requires it), so a concurrent test doing HTTP on 127.0.0.1, or a mysqli connect over TCP, makes recvfrom() return a frame and the assert flips. Seen on LINUX_X32_DEBUG_ZTS as bool(false) where bool(true) was expected, with the other three cases in the file passing.

--CONFLICTS-- all is what ext/tidy/tests/parsing_file_too_large.phpt already uses for a test that cannot share the machine.

One caveat worth stating: the race is rare, so a green CI run here does not prove the fix, it just fails to disprove it. The argument is that the assertion is unsound under any concurrency and this removes the concurrency.

@iliaal
iliaal requested a review from devnexen as a code owner July 16, 2026 18:37
The no-data case binds an ETH_P_ALL packet socket to lo and asserts that a
non-blocking recvfrom() finds nothing, which only holds while no other test
puts a frame on loopback. run-tests spawns workers in parallel and the job
runs as root, so any concurrent test that talks to localhost makes the socket
capture a frame and recvfrom() returns data instead of failing.

Observed on LINUX_X32_DEBUG_ZTS: bool(false) where bool(true) was expected.

Closes phpGH-22773
@iliaal
iliaal merged commit 331916c into php:master Jul 17, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants