Skip to content

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

Closed
iliaal wants to merge 1 commit into
masterfrom
fix/afpacket-test-parallel-unsafe
Closed

ext/sockets: run the AF_PACKET error test in isolation#178
iliaal wants to merge 1 commit into
masterfrom
fix/afpacket-test-parallel-unsafe

Conversation

@iliaal

@iliaal iliaal commented Jul 16, 2026

Copy link
Copy Markdown
Owner

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.

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 force-pushed the fix/afpacket-test-parallel-unsafe branch from 3f10641 to 59b9211 Compare July 16, 2026 18:38
@iliaal

iliaal commented Jul 16, 2026

Copy link
Copy Markdown
Owner Author

Promoted upstream: php#22773

@iliaal iliaal closed this Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant