fix(v4.0.0): a node blocked at a port with no one on it is given an error, not left there

A node writing to a node that was stuck, and was then killed, stayed
blocked for ever: killing a stuck node could cost its neighbours.  And on
the hosted and bare-metal products a write to an empty port, 5 7 PORT!,
ended the program with "the node stopped".

Now a node that can take an error, blocked writing to or reading from one
port that nothing is wired to -- nothing ever was, or what was there has
been killed or the wire cut -- has error 18, No one on that port, raised
on it and goes on.  A bare node waits as on the fabric; so does a node
whose neighbour is asleep, and one reading "any port".

test_host_unit.c: Hera kills node 14 while node 12 is blocked writing to
it.  It failed first: 12 stayed blocked.  test_fabric.c: a bare node still
waits.  hosted-check types 5 7 PORT! and goes on; it failed first too.

make -C v4 test, sanitize and hosted-check pass; amd64, aarch64 and
riscv64 boot, POST 538 of 538, dict_hash 0x5f0a949a6fc8ef2b on all six:
logs/20261007-121743, -122008, -122337.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rajames
2026-10-07 12:25:35 -04:00
co-authored by Claude Opus 5.5
parent 18adf59091
commit bc6deab3f5
17 changed files with 609 additions and 4 deletions
+12
View File
@@ -54,11 +54,23 @@ typedef struct {
typedef struct {
v4_place *place;
unsigned capacity;
v4_cell gone_error; /* see v4_fabric_gone_error; 0: none */
} v4_fabric;
/* An empty fabric with room for `capacity` nodes, in `places`. */
void v4_fabric_init(v4_fabric *f, v4_place *places, unsigned capacity);
/* A PORT WITH NOTHING ON IT. On the fabric a node that writes to such a
* port, or reads from it, waits for ever (docs/v4.0.0/MESH.md 4.1). That
* is so here for a bare node. But a node that can take an error is not
* left there: when it is blocked writing to, or reading from, one port that
* nothing is wired to -- because nothing ever was, or because what was
* there has been removed or the wire cut -- the error `code` is raised on
* it and it goes on (node.h, v4_node_port_gone). A node whose neighbour is
* asleep waits, and so does one reading "any port". With `code` 0, which
* is how a fabric begins, nothing is raised. */
void v4_fabric_gone_error(v4_fabric *f, v4_cell code);
/* More room: `places`, of `capacity` no less than before, takes over; every
* node keeps its number and its wiring. */
void v4_fabric_grow(v4_fabric *f, v4_place *places, unsigned capacity);
+5
View File
@@ -60,6 +60,11 @@ typedef struct {
v4_cell block_window;
} v4_image;
/* The nucleus's error for a node blocked at a port with no one on it
* (v4/capsule/core.v4's list; node.h, v4_node_port_gone): "No one on that
* port". */
#define V4_ERROR_NO_ONE 18
/* The description of the nucleus built from v4/capsule (the generated file
* defines it). */
extern const v4_image v4_capsule_image;
+10
View File
@@ -214,6 +214,16 @@ void v4_node_port_attach(v4_node *n, v4_cell base);
/* The neighbour has taken what the node wrote. */
void v4_node_port_served(v4_node *n);
/* THERE IS NO ONE ON THE PORT the node is blocked at -- writing to it, or
* reading from that one port -- and there will not be. A node that can
* take an error (it has an error register and a fault table: node.h,
* v4_node_error_attach, v4_node_fault_attach) is let go and the error
* `code` is raised on it, as if it had stored the code to its error
* register: what it was doing ends there. Returns 1. A node that cannot
* stays blocked, as on the fabric, and 0 is returned; so is 0 for a node
* that is not blocked at a port, or is reading "any port". */
int v4_node_port_gone(v4_node *n, v4_cell code);
/* The neighbour on `port` writes `value`: the node, blocked reading that
* port or "any", is unblocked and will fetch it. */
void v4_node_port_give(v4_node *n, unsigned port, v4_cell value);