[MG_Backend, MG_Impl, MG_Remote, MG_Test, MG_IntegrationTest, CI] (Disaggregated): P5f f1 - the dual-block rehearsal: per-role PipeInputs, the MOBILEGL_IPC_ROLE_SPLIT_STATE knob, and the named-Fatal arm that makes the red a census

This commit is contained in:
2026-09-19 09:59:33 -04:00
parent e75e00cb7a
commit cfcc12f73a
15 changed files with 833 additions and 13 deletions
+61
View File
@@ -160,6 +160,20 @@ namespace MobileGL::MG_Pipe {
// MGPipeBarrierPullAdmitted is generated from those three tables (ID-116); there is no
// list here to drift.
void CountBarrierPull(MGPipeInputField field, MGPipeVerb verb) {
// P5f (f1), P5F-WIRE-COMPLETENESS.md §4: UNDER THE DUAL-BLOCK REHEARSAL EVERY
// BARRIER-PULLED READ IS A NAMED FATAL, unconditionally - ahead of the barriered
// question, ahead of the strict knob, ahead of the counter. The server block has no
// residual fill to answer from, so the value the read would return is not "torn"
// or "stale" but ABSENT: the field's stamp was withdrawn by the server's own verb
// boundary and nothing on this side of the role split ever writes it. Letting the
// read proceed would hand the backend default storage - or, for the O-class rows
// with no null check, an empty SharedPtr to dereference - which is an UNNAMED
// crash exactly where the rehearsal exists to produce a named one. The red is the
// census (Harness/dualblock-expected-fatals.txt), so the marker keeps the strict
// grammar with the knob's own name as the reason.
if (MGPipeRoleSplitActive()) {
StrictBarrierPullFatal(field, verb, "MOBILEGL_IPC_ROLE_SPLIT_STATE=1");
}
if (!MGPipeApplierCurrentRecordIsBarriered()) {
StrictBarrierPullFatal(field, verb, "UNBARRIERED, the client did not fill it");
}
@@ -260,8 +274,50 @@ namespace MobileGL::MG_Pipe {
static void SetServerStamped(PipeInputs& inputs, Bool stamped) {
inputs.m_serverStampedVerb = stamped;
}
// P5f (f1): the server block's identity half of the stamp door (CONTRACT-P5E §3.2).
// The client's SetIdentity lives in MG_Impl's MGPipeFillAccess and writes the CLIENT
// block now; this one is how the server block learns which served context it describes
// without MG_Impl being in the process at all.
static void SetIdentity(PipeInputs& inputs, Bool live, const void* identity) {
inputs.m_live = live;
inputs.m_contextIdentity = identity;
}
};
// ---- P5f (f1): the dual-block rehearsal's selection functions (PipeInputs.h) -----------
//
// MGPipeRoleSplitActive is deliberately NOT latched: it is two global loads, asked once per
// verb on the fill side and once per verb boundary on the stamp side, and a latch is a
// second thing a test that flips the knob mid-process would have to know about.
Bool MGPipeRoleSplitActive() {
return MG_Config::Ipc.RoleSplitState &&
MG_Config::Transport != MG_Config::TransportMode::Monolith;
}
PipeInputs& MGPipeClientInputs() {
return MGPipeRoleSplitActive() ? gPipeInputsClientBlock : gPipeInputs;
}
void MGPipeClientClearVerbBoundary() {
MGPipeStampAccess::SetServerStamped(MGPipeClientInputs(), false);
}
void MGPipeServerBlockNoteIdentity() {
if (!MGPipeRoleSplitActive()) return;
// The server cannot name the client's GLContext - under a real transport it is in
// another process - so the identity the server block carries is the server's OWN
// served-context clock: MGPipeApplierContextSerial moves exactly when the served
// context does (MGPipeApplierReset), which is all the backends' per-context memo keys
// ask of an identity. The odd-encoding keeps the token non-null at serial 0: a null
// identity reads as a hit against DirectGLES' zero-initialised fb-slot memo cache and
// hands out a null slot - an unnamed crash where the rehearsal exists to produce a
// named one.
const Uint64 serial = MGPipeApplierContextSerial();
MGPipeStampAccess::SetIdentity(gPipeInputs, true,
reinterpret_cast<const void*>(static_cast<std::uintptr_t>(
(serial << 1) | Uint64{1})));
}
void MGPipeServerStampVerbBoundary(MGPipeVerb verb) {
PipeInputs& inputs = gPipeInputs;
// P5e (gl), ID-115: THE POSITIVE CONTROL'S ONLY HONEST SIGNAL, and it belongs HERE
@@ -302,6 +358,11 @@ namespace MobileGL::MG_Pipe {
filled.FilledGen[i] = serial & (Uint64{0} - bit);
}
MGPipeStampAccess::SetServerStamped(inputs, true);
// P5f (f1): the server block's identity rides the stamp (CONTRACT-P5E §3.2's
// "SetIdentity moves to ApplyOne" - the stamp is the per-verb half of ApplyOne, and
// refreshing here rather than once at Attach keeps the token in step with
// MGPipeApplierContextSerial across a context switch). A no-op with the rehearsal off.
MGPipeServerBlockNoteIdentity();
}
void MGPipeServerClearVerbBoundary() { MGPipeStampAccess::SetServerStamped(gPipeInputs, false); }
+55
View File
@@ -834,6 +834,61 @@ namespace MobileGL::MG_Pipe {
// (P3a; the exit-time heap corruption this closes is p3a-results/exit-order-v1.md.)
inline PipeInputs& gPipeInputs = *new PipeInputs();
#if MOBILEGL_BUILD_DISAGGREGATED
// ============================================================================
// P5f (f1), P5F-WIRE-COMPLETENESS.md §4: THE DUAL-BLOCK REHEARSAL
// ============================================================================
//
// One gPipeInputs served both roles because the verb barrier (R-1) made "the client filled
// it" and "the server is reading it" mutually exclusive in TIME on the same object. The
// rehearsal removes the same-object half of that sentence: under
// MOBILEGL_IPC_ROLE_SPLIT_STATE=1 the client's residual fill writes the CLIENT block below
// and the backend/applier keep reading gPipeInputs, which is the SERVER block. Every path
// that worked only because the two were one object - a BARRIER-PULLED field, a sticky
// forward's read of the fill side's stamps - then has no value to read, and the read
// becomes a NAMED Fatal{UnmigratedPipeInput, "<field>@<verb>"} (CountBarrierPull's
// dual-block arm, PipeInputs.cpp) instead of a silent cross-role answer.
//
// THE READ SIDE'S SPELLING DOES NOT MOVE. gPipeInputs remains the server-role block, so the
// 379 MGB_CTX sites and PipeApply.cpp's applier writes are untouched; the only new spelling
// is on the fill side (MG_Impl/Pipe/PipeFill.cpp), which asks MGPipeClientInputs(). Under
// monolith transport - every unit and integration-gpu lane of a split build - the selection
// folds back to the single shared block and behaviour is byte-for-byte the old one.
//
// Same leak-at-exit storage as gPipeInputs above, for the same reason.
inline PipeInputs& gPipeInputsClientBlock = *new PipeInputs();
// PipeInputs.cpp. Whether the rehearsal is armed: the knob AND a real transport (and not
// the verify build, which ConfigLoader forces off). Constant for the life of the process.
Bool MGPipeRoleSplitActive();
// PipeInputs.cpp. THE FILL SIDE'S ONE NEW SPELLING: the client block when the rehearsal is
// armed, gPipeInputs otherwise. Everything in MG_Impl/Pipe/PipeFill.cpp that used to spell
// gPipeInputs spells this instead.
PipeInputs& MGPipeClientInputs();
// PipeInputs.cpp. The client-role half of MGPipeServerClearVerbBoundary: clears the stamp
// flag on the FILL side's block. With the rehearsal off that IS gPipeInputs, so the two
// client call sites keep their old semantics exactly; with it on the client block's flag is
// never raised (nothing server-stamps it) and the clear is a no-op - which is the point:
// the client no longer reaches into the server's block at all.
void MGPipeClientClearVerbBoundary();
// PipeInputs.cpp. CONTRACT-P5E §3.2's other half: the server block's identity is
// SERVER-OWNED. Called from PipeApplier::Attach and from MGPipeServerStampVerbBoundary;
// with the rehearsal armed it sets m_live and points m_contextIdentity at a token derived
// from MGPipeApplierContextSerial() - the server's own served-context clock, which is what
// moves when the served context does. Without it the server block's ContextIdentity() would
// stay nullptr, and DirectGLES' fb-slot memo cache compares identity FIRST (a nullptr
// against its own nullptr initialiser reads as a hit and hands out a null slot): an
// unnamed crash where the rehearsal exists to produce a named one. A no-op with the
// rehearsal off, so the client's per-verb SetIdentity keeps owning the shared block there.
void MGPipeServerBlockNoteIdentity();
#else
// The push-without-transport build has one role and one block, so the fill side's spelling
// folds onto gPipeInputs and PipeFill.cpp reads identically in both build flavours. An
// inline that no caller in such a build ever has a reason to call twice - the disaggregated
// arm above is the real one.
inline PipeInputs& MGPipeClientInputs() { return gPipeInputs; }
#endif
// Every field has storage or is forwarded, and nothing else.
#define MGP_INPUT_COUNT_ONE(Field, Member) +1
static_assert(0 MGP_INPUT_STORAGE_LIST(MGP_INPUT_COUNT_ONE) + kMGPipeForwardedFieldCount == kMGPipeInputFieldCount,