FAIL

cockpit architecture check

2 errors, 0 warnings. Trace demo/cockpit/traces/deadlock.kev: QNX 8.0.0 on x86pc, 2 CPUs, 6.00 s, 33,405 events.

Architecture

display to camera: 0 messagesdisplay to logger: 0 messagesdisplay to nav: 1 messagesgps to nav: 1 messagesnav to gps: 1 messagesnav to logger: 0 messagesgpsnavcameraloggerdisplay
  • allowed, used
  • allowed, not seen
  • not in contract
  • deadlock loop
  • path in a finding

Findings

  1. deadlock: nav -> gps -> nav wait-cyclestart here
  2. gps talks to nav, which the contract does not allow unexpected-edge
errorwait-cycle

deadlock: nav -> gps -> nav

Wait-for loop nav -> gps -> nav: gps is SEND-blocked on nav; nav is REPLY-blocked on gps. Nobody in the loop can ever reply. Also stuck behind it: display.

Evidence: trace events 63860, 63971

Show the 8 trace events behind this
EventTimeWhat happened
638402233.923 msdisplay[tid 1] MsgSend to nav (coid 0x40000001, chid 1) message '\x02\x10'
638502233.943 msnav[tid 1] MsgReceive got the message from display[tid 1]
638602234.026 msnav[tid 1] MsgSend to gps (coid 0x40000001, chid 1) message '\x01\x10'
638702234.051 msgps[tid 1] MsgReceive got the message from nav[tid 1]
639712234.502 msgps[tid 1] MsgSend to nav (coid 0x40000002, chid 1) message '\x05\x10'
-63972 (note)-at trace end gps[tid 1] is still SEND-blocked on nav (no reply to event 63971)
-63861 (note)-at trace end nav[tid 1] is still REPLY-blocked on gps (no reply to event 63860)
-63841 (note)-at trace end display[tid 1] is still REPLY-blocked on nav (no reply to event 63840)
Why, according to claude-opus-5-5 confidence high

While handling nav's MSG_POSITION request (63860/63870), gps_handle() calls MsgSend() back to nav for a MSG_HINT (63971) before replying. nav's only thread is REPLY-blocked in its own MsgSend() to gps, so it can never MsgReceive() the hint; gps stays SEND-blocked on nav and nav stays REPLY-blocked on gps forever. display, waiting on nav (63840), freezes behind the loop. gps -> nav is also not an allowed edge in blueprint.yaml.

At fault: MsgSend in gps (gps_handle sends MSG_HINT to nav before MsgReply to nav)

Fix: Remove the gps -> nav call. A server must not send to its own client. The contract only allows nav -> gps, so gps must answer MSG_POSITION from its own state. If gps really needs route context, nav should put it in the MSG_POSITION request, or gps should get it later through a non-blocking pulse, never a MsgSend back up the chain.

Proposed patch
--- a/cockpit.c
+++ b/cockpit.c
@@ static int gps_handle(int rcvid, cockpit_msg_t *msg, cockpit_msg_t *reply) {
     (void)rcvid;
-    if (has_fault("deadlock") && msg->type == MSG_POSITION) {
-        /* The regression: gps wants a route hint from nav before answering.
-         * nav is blocked waiting on us, so neither side ever replies. */
-        if (gps_nav == -1) {
-            gps_nav = connect_to("cockpit-nav");
-        }
-        cockpit_msg_t hint;
-        ask(gps_nav, MSG_HINT, msg->seq, "hint?", &hint);
-    }
+    /* gps is a leaf server: it must never MsgSend() to nav, its own client.
+     * Any hint nav wants to give belongs in the MSG_POSITION request (msg->text). */
     snprintf(reply->text, sizeof(reply->text), "pos %d.%03d", 50, 450 + msg->seq % 100);
     return 0;
 }

Cites events 63840, 63850, 63860, 63870, 63971, -63972, -63861, -63841 · Docs: MsgSend MsgReceive MsgReply Synchronous message passing

errorunexpected-edge

gps talks to nav, which the contract does not allow

1 message from gps to nav on chid 1. Allowed servers for gps: none.

Evidence: trace events 63971

Show the 5 trace events behind this
EventTimeWhat happened
638602234.026 msnav[tid 1] MsgSend to gps (coid 0x40000001, chid 1) message '\x01\x10'
638702234.051 msgps[tid 1] MsgReceive got the message from nav[tid 1]
639712234.502 msgps[tid 1] MsgSend to nav (coid 0x40000002, chid 1) message '\x05\x10'
-63972 (note)-at trace end gps[tid 1] is still SEND-blocked on nav (no reply to event 63971)
-63861 (note)-at trace end nav[tid 1] is still REPLY-blocked on gps (no reply to event 63860)
Why, according to claude-opus-5-5 confidence high

With COCKPIT_FAULT=deadlock, gps_handle() sends MSG_HINT to nav (event 63971) while it is still holding nav's unreplied MSG_POSITION request (63860/63870). nav's only thread is REPLY-blocked in MsgSend on gps, so it can never MsgReceive the hint. gps stays SEND-blocked on nav (-63972) and nav stays REPLY-blocked on gps (-63861): a send cycle the contract forbids (gps may send to no one), and it ends in deadlock.

At fault: MsgSend in gps (gps_handle -> ask(gps_nav, MSG_HINT)) to nav while nav is blocked in MsgSend to gps

Fix: Remove the gps -> nav call. gps must reply to MSG_POSITION from its own state and never send to nav. Messages must flow only down the allowed graph (nav -> gps). If gps really needs nav's route data, nav should push it in its own request, for example as a field of MSG_POSITION. Do not change the contract: allowing gps -> nav would reintroduce the cycle.

Proposed patch
--- a/cockpit.c
+++ b/cockpit.c
@@ static int gps_nav = -1;
-static int gps_nav = -1;
-
 static int gps_handle(int rcvid, cockpit_msg_t *msg, cockpit_msg_t *reply) {
     (void)rcvid;
-    if (has_fault("deadlock") && msg->type == MSG_POSITION) {
-        /* The regression: gps wants a route hint from nav before answering.
-         * nav is blocked waiting on us, so neither side ever replies. */
-        if (gps_nav == -1) {
-            gps_nav = connect_to("cockpit-nav");
-        }
-        cockpit_msg_t hint;
-        ask(gps_nav, MSG_HINT, msg->seq, "hint?", &hint);
-    }
+    /* gps is a leaf server: it never sends to nav (nav -> gps only). Any hint
+     * nav wants to give must travel inside nav's own request. */
     snprintf(reply->text, sizeof(reply->text), "pos %d.%03d", 50, 450 + msg->seq % 100);
     return 0;
 }

Cites events 63860, 63870, 63971, -63972, -63861 · Docs: MsgSend MsgReceive MsgReply Synchronous message passing

Message traffic

ClientServerIn contractMessagesRepliedErrorsUnansweredMedian replyWorst replyBudget
displaynavyes1001--50 ms
gpsnavno1001--50 ms
navgpsyes1001--20 ms