Skip to content

Commit cddf53d

Browse files
DIAGNOSTIC (temporary): verbose logging for macOS sanitized Socket test 8
test_sk1_three_sockets_two_ready_count fails only on macOS+ASan. Add temporary logging to capture the actual values on the real runner: - test: SK1DBG sent/poll1 + a level-triggered re-poll (poll2, no read between) to tell an async-delivery snapshot (poll2 sees 2) from a wrong result (poll2 still off), plus the fds and each events_ready. - SocketPoll: SOCKPOLLDBG raw poll ret + per-fd events/revents. To be reverted once the CI log pins the failure mode.
1 parent 42c3ea5 commit cddf53d

2 files changed

Lines changed: 51 additions & 1 deletion

File tree

Source/Misra/Sys/Socket.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,18 @@ i32 SocketPoll(SocketPollItem *items, u32 count, i32 timeout_ms) {
10331033
}
10341034
#endif
10351035

1036+
// --- TEMP DIAGNOSTIC (remove after CI) ---
1037+
LOG_ERROR("SOCKPOLLDBG count={} timeout={} ret={}", count, timeout_ms, ret);
1038+
for (u32 di = 0; di < count && di < 8; ++di) {
1039+
LOG_ERROR(
1040+
"SOCKPOLLDBG fd[{}]={} events={x} revents={x}",
1041+
di,
1042+
(i64)items[di].fd,
1043+
(u32)pfds[di].events,
1044+
(u32)pfds[di].revents
1045+
);
1046+
}
1047+
10361048
if (ret >= 0) {
10371049
for (u32 i = 0; i < count; ++i) {
10381050
u32 ready = 0;

Tests/Std/Socket.c

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,18 @@ bool test_sk1_three_sockets_two_ready_count(void) {
387387
}
388388

389389
// Make server0 and server2 readable; server1 stays idle.
390-
bool sent = SocketSend(&p0.client, "A", 1) == 1 && SocketSend(&p2.client, "C", 1) == 1;
390+
i64 s0 = SocketSend(&p0.client, "A", 1);
391+
i64 s2 = SocketSend(&p2.client, "C", 1);
392+
bool sent = s0 == 1 && s2 == 1;
393+
// --- TEMP DIAGNOSTIC (remove after CI) ---
394+
WriteFmt(
395+
"SK1DBG sent s0={} s2={} fd0={} fd1={} fd2={}\n",
396+
s0,
397+
s2,
398+
(i64)p0.server.fd,
399+
(i64)p1.server.fd,
400+
(i64)p2.server.fd
401+
);
391402

392403
SocketPollItem items[3] = {0};
393404
items[0].fd = p0.server.fd;
@@ -398,6 +409,33 @@ bool test_sk1_three_sockets_two_ready_count(void) {
398409
items[2].events_requested = SOCKET_POLL_READ;
399410

400411
i32 n = SocketPoll(items, 3, 1000);
412+
// --- TEMP DIAGNOSTIC (remove after CI) ---
413+
WriteFmt(
414+
"SK1DBG poll1 n={} r0={x} r1={x} r2={x}\n",
415+
n,
416+
items[0].events_ready,
417+
items[1].events_ready,
418+
items[2].events_ready
419+
);
420+
// Re-poll the same fds without reading: poll is level-triggered, so a
421+
// socket that's genuinely readable stays readable. If poll1 missed one
422+
// because its byte was still in flight (async loopback), poll2 now sees
423+
// it -> timing snapshot. If poll2 is still wrong -> a real defect.
424+
SocketPollItem items2[3] = {0};
425+
items2[0].fd = p0.server.fd;
426+
items2[0].events_requested = SOCKET_POLL_READ;
427+
items2[1].fd = p1.server.fd;
428+
items2[1].events_requested = SOCKET_POLL_READ;
429+
items2[2].fd = p2.server.fd;
430+
items2[2].events_requested = SOCKET_POLL_READ;
431+
i32 n2 = SocketPoll(items2, 3, 1000);
432+
WriteFmt(
433+
"SK1DBG poll2 n={} r0={x} r1={x} r2={x}\n",
434+
n2,
435+
items2[0].events_ready,
436+
items2[1].events_ready,
437+
items2[2].events_ready
438+
);
401439

402440
bool ok = sent && n == 2 && (items[0].events_ready & SOCKET_POLL_READ) != 0 &&
403441
(items[1].events_ready & SOCKET_POLL_READ) == 0 && (items[2].events_ready & SOCKET_POLL_READ) != 0;

0 commit comments

Comments
 (0)