mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-11-21 00:41:57 +09:00
[MG_Pipe, MG_Backend, MG_Remote, MG_Test, scripts] (P7): the Magma wire fatals and the two Staged aborts go through Session::Fail
Five deaths in the split server image raised their own std::abort(). Three of them are funnels - MagmaWireFatal (Renderer/WireFramebuffer.inc), WireDescriptorFatal (Renderer/UniformManager.cpp) and WireBufferLegacyFatal (Renderer/WireDraw.inc) - and the fifteen `@P7` refusals on the tree (8 in UniformManager.cpp, 4 in WireFramebuffer.inc, 2 in WireDraw.inc, 1 in VulkanRenderer.cpp; plan section 1.3's count confirmed) all die through two of them. Every one of those deaths published NO SessionFault frame, so the peer read a bare EOF; bumped NO SessionFaultCount(), so exit gate S8 could neither confirm nor falsify it; and carried a hand-typed family word with no path to FatalFamilies.def's projection. MG_Backend may not name an MG_Remote symbol on its own account, so the route is a seam in MG_Pipe with MGP_TRIP_WIRE_REPORT's shape (PipeApply.cpp:66, and the new code sits beside it): MG_Pipe/PipeSessionFail.h declares MGPipeSessionFail, PipeApply.cpp defines it inside `#if MOBILEGL_BUILD_DISAGGREGATED`, the DEFAULT behaviour is byte-identical to what the three funnels did on their own, and MG_Remote::InstallPipeSessionFailHook() points it at SessionFail. The install is in InitServerRoleCommon (MG_Backend/Init.cpp), step 0, because that is the one function BOTH server roles run - the inproc role and the spawn/TCP session child - so there is no per-transport install to get wrong. MGPipeFatalFamily is a two-value boundary enum, NOT MGFatalFamily cast to an integer: the .def's enumerators are positional and a row inserted in its middle would silently re-point every hook call at a different family. FatalFunnel.cpp's adapter is the one place the two vocabularies meet, as a switch with a named default. The family word stays UnmigratedVerb rather than becoming a new MagmaWireRefusal. Three reasons: the message strings are required to stay byte-identical (5.2), and the retrace refusal censuses recorded since P5b count these deaths by that word - a rename invalidates every `@P7` measurement taken against them; `Magma:` in the detail already separates the Magma arm from the GLES UnmigratedVerb deaths, so a new word adds no discrimination a grep does not have; and its wire projection would be ProtocolCorruption, exactly UnmigratedVerb's. Recorded for the integrator. Ph slice (2) in the same commit: Server/StagedShadow.h's RequireCovered and Server/StagedTextureStore.h's RequireLevelBytes were MGLOG_F + bare abort. Both are inside MG_Remote already, so they call SessionFail directly, message verbatim; check_include_closure.py's four probes do not reach either header and the gate is green. Census: 83 abort sites -> 79 over 20 files (five sites retired, one gained for the seam's no-hook default, which is argued into FUNNEL_SITES), baseline rewritten in this commit - the downward ratchet's notice is what asked for it. Two gate bugs the widening exposed and this commit fixes: the SessionFail call regex also matched `MGPipeSessionFail(` (a lookbehind now), and a funnel's anchor needed a wider window than a marker's (kFunnelAnchorWindow). Red-once, three ways. Pointing MagmaWireFatal back at its own abort reds the census naming WireFramebuffer.inc 0 -> 1. Making the seam skip the hook reds both new death cases - `TheMagmaWireVerbDeathReachesSessionFailAndBumpsTheFaultCount` on the exit code, because it reads SessionFaultCount() out of a SIGABRT handler and gets 0 instead of 1, and `TheSeamHandsTheInstalledHookItsFamilyAndItsLineVerbatim` on the line the hook echoed.
This commit is contained in:
@@ -8,12 +8,17 @@
|
||||
|
||||
// P6 `dl` (CONTRACT-P6 5.2). The Fatal-family table and its projection onto the wire FatalCode.
|
||||
|
||||
#include <MG_Pipe/PipeSessionFail.h>
|
||||
#include <MG_Remote/FatalFamily.h>
|
||||
#include <MG_Remote/FatalFunnel.h>
|
||||
#include <MG_Remote/Protocol/generated/protocol_generated.h>
|
||||
|
||||
#include <flatbuffers/flatbuffers.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <csignal>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
@@ -29,6 +34,27 @@ namespace {
|
||||
#undef X
|
||||
};
|
||||
|
||||
#if !defined(_WIN32)
|
||||
// P7 wave 0. SessionFaultCount() is the only thing the funnel leaves behind that a test can
|
||||
// read, and SessionFail aborts before returning - so the counter has to be read from INSIDE
|
||||
// the dying process. A SIGABRT handler turns it into the child's exit code: kFaultExitBase +
|
||||
// n. "The funnel was reached exactly once" is then a value the parent asserts rather than a
|
||||
// log line it has to parse, and a seam that bypassed the funnel would exit 0x60, not 0x61.
|
||||
constexpr int kFaultExitBase = 0x60;
|
||||
|
||||
void ReportFaultCountAndExit(int) {
|
||||
std::_Exit(kFaultExitBase + static_cast<int>(MobileGL::MG_Remote::SessionFaultCount()));
|
||||
}
|
||||
|
||||
// A hook of the TEST's own, to prove what the seam hands across independently of what
|
||||
// SessionFail then does with it. It echoes and returns; MGPipeSessionFail's contract is that
|
||||
// it aborts anyway, which is also under test here.
|
||||
void EchoingHook(MobileGL::MG_Pipe::MGPipeFatalFamily family, const char* line) {
|
||||
std::fprintf(stderr, "seam-saw family=%u line=%s\n", static_cast<unsigned>(family), line);
|
||||
std::fflush(stderr);
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST(FatalFamily, TheTableAndTheEnumAgreeOnCount) {
|
||||
@@ -84,6 +110,75 @@ TEST(FatalFamily, TheAnchorFamiliesProjectWhereTheirMeaningSays) {
|
||||
EXPECT_EQ(FatalCodeForFamily(MGFatalFamily::UnmigratedVerb), FatalCode::ProtocolCorruption);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// P7 wave 0: the seam MG_Backend's three Magma wire funnels die through (MG_Pipe/
|
||||
// PipeSessionFail.h). Until this package they logged and raised their own std::abort(), so
|
||||
// fifteen `@P7` refusals plus WireBufferLegacyFatal published no SessionFault to the peer, bumped
|
||||
// no SessionFaultCount() and were invisible to the census gate. These three cases are the
|
||||
// red-once for that: delete InstallPipeSessionFailHook()'s call in InitServerRoleCommon and the
|
||||
// first two go red on the exit code, point a funnel back at MGLOG_F + abort and all three do.
|
||||
|
||||
TEST(FatalFunnelSeam, InstallingTheHookPointsTheSeamSomewhereOtherThanItsDefault) {
|
||||
using namespace MobileGL;
|
||||
ASSERT_EQ(MG_Pipe::MGPipeSessionFailHookInstalled(), nullptr)
|
||||
<< "the seam was already installed before this case ran; the binary's default is the "
|
||||
"no-hook one and only a server-role init should change it";
|
||||
MG_Remote::InstallPipeSessionFailHook();
|
||||
EXPECT_NE(MG_Pipe::MGPipeSessionFailHookInstalled(), nullptr);
|
||||
// Restored, so the two cases below start from the same state whichever order they run in.
|
||||
MG_Pipe::MGPipeInstallSessionFailHook(nullptr);
|
||||
EXPECT_EQ(MG_Pipe::MGPipeSessionFailHookInstalled(), nullptr);
|
||||
}
|
||||
|
||||
TEST(FatalFunnelSeam, TheMagmaWireVerbDeathReachesSessionFailAndBumpsTheFaultCount) {
|
||||
#if defined(_WIN32)
|
||||
GTEST_SKIP() << "the seam's proof forks and reads a signal, which is POSIX only - the same "
|
||||
"reason MG_Test/Wire's spawn cases are POSIX only";
|
||||
#else
|
||||
using namespace MobileGL;
|
||||
// WireFramebuffer.inc's MagmaWireFatal, character for character - the funnel eleven of the
|
||||
// fifteen `@P7` refusals die through.
|
||||
EXPECT_EXIT(
|
||||
{
|
||||
std::signal(SIGABRT, &ReportFaultCountAndExit);
|
||||
MG_Remote::InstallPipeSessionFailHook();
|
||||
MG_Pipe::MGPipeSessionFail(MG_Pipe::MGPipeFatalFamily::UnmigratedVerb,
|
||||
"MGPipe: Fatal{UnmigratedVerb, \"Magma:%s\"}",
|
||||
"unit-probe");
|
||||
},
|
||||
::testing::ExitedWithCode(kFaultExitBase + 1),
|
||||
"Fatal\\{UnmigratedVerb, \"Magma:unit-probe\"\\}")
|
||||
<< "the Magma wire funnel did not end through SessionFail: either the line is not the "
|
||||
"site's own any more, or SessionFaultCount() did not move - which is what exit gate "
|
||||
"S8 reads and what every telemetry consumer of the funnel depends on";
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(FatalFunnelSeam, TheSeamHandsTheInstalledHookItsFamilyAndItsLineVerbatim) {
|
||||
#if defined(_WIN32)
|
||||
GTEST_SKIP() << "POSIX only, as above";
|
||||
#else
|
||||
using namespace MobileGL;
|
||||
// WireDraw.inc's WireBufferLegacyFatal, character for character. Through a hook of the test's
|
||||
// own rather than MG_Remote's, so what is under test is the SEAM - that the family enum and
|
||||
// the fully formatted line cross intact - and not what SessionFail then does with them. The
|
||||
// hook returns; MGPipeSessionFail must still abort, which is why this is an exit assertion.
|
||||
EXPECT_EXIT(
|
||||
{
|
||||
MG_Pipe::MGPipeInstallSessionFailHook(&EchoingHook);
|
||||
MG_Pipe::MGPipeSessionFail(
|
||||
MG_Pipe::MGPipeFatalFamily::RoleViolation,
|
||||
"MGPipe: Fatal{RoleViolation, \"buffer-legacy-arm\"} (Magma P7 buffer consumer)");
|
||||
},
|
||||
::testing::KilledBySignal(SIGABRT),
|
||||
"seam-saw family=1 line=MGPipe: Fatal\\{RoleViolation, \"buffer-legacy-arm\"\\} "
|
||||
"\\(Magma P7 buffer consumer\\)")
|
||||
<< "the seam changed what it hands across: either the family ordinal moved (which would "
|
||||
"re-point FatalFunnel.cpp's adapter arm at the wrong .def row) or the line is no "
|
||||
"longer the site's own string, which CONTRACT-P6 5.2 requires to stay byte-identical";
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(FatalFamily, TheSessionFaultFrameCarriesTheFamilyAndItsCode) {
|
||||
// `dl` step three (5.2): the Fatal frame a dying session publishes carries the full family
|
||||
// WORD beside the coarse code, so a peer names which family ended the session instead of
|
||||
|
||||
Reference in New Issue
Block a user