[MobileGL, MG_Backend, MG_Impl, docs] (P7): the FATAL=0 verify summary is written before Debug::Close, so the client half keeps its lines

- the summary line ("N divergence(s) survived MOBILEGL_PIPE_VERIFY_FATAL=0") came from a namespace-scope static's destructor, which runs from __run_exit_handlers AFTER MobileGL::Destroy has called MG_Util::Debug::Close(); Close nulls the role's sink, Log.cpp's WriteToFile re-runs InitFile() for the next line, and InitFile opens the role's file with "w" - so that one line was the only line the client half of every FATAL=0 run kept (121 B: the entry compare's reports, the arming line and the config dump all gone, on the split corrupt / read-corrupt entries and on the monolith arm's VerifyCorrupted. log alike)
- fixed in verify-only code, since Log.cpp is in the pull build and G1 admits no byte there: VerifyState gains FlushSummary(), which reports the count once (idempotent - a second call with nothing new, the destructor's own included, writes nothing); MGPipeVerifyFlushSummary() exports it from PipeFill.cpp, declared in PipeInputs.h beside the other verify-only entry points, and DestroyImpl calls it right before Close under #if MOBILEGL_PIPE_VERIFY
- the note's A' paragraph no longer says the entry compare is silent on the pack field - it reports it (the client summaries read 4 divergence(s) on DirectGLES / 3 on DirectVulkan); the red line can only come from the read arm because of where=read and the server-role file, and the paragraph now names the truncation and carries the numbers
- measured on the same entry, pipe-verify-split-read-corrupt-DirectGLES.client.log: 121 B / 1 line before, 7461 B / 85 lines after (DirectVulkan 121 B / 1 line -> 7386 B / 85 lines), with the where=entry report (1 each; the summary's 4 / 3 is that one plus the server's 3 / 2 read reports, the counter being process-wide) and the arming line present and the summary as the last line
This commit is contained in:
2026-09-22 23:02:08 -04:00
parent ffc4fb7d77
commit 07f4e3acef
4 changed files with 61 additions and 8 deletions
+11
View File
@@ -21,6 +21,9 @@
#include <MG_Util/ShaderTranspiler/ShaderCompiler.h>
#include <MG_State/GLState/ProgramState/ProgramTranslationCache.h>
#include <MG_Util/ShaderTranspiler/TranslationCache.h>
#if MOBILEGL_PIPE_VERIFY
#include <MG_Backend/MGPipe/PipeInputs.h> // MGPipeVerifyFlushSummary, before Debug::Close in DestroyImpl
#endif
#include <atomic>
#include <mutex>
@@ -99,6 +102,14 @@ namespace MobileGL {
MG_State::GLState::ClearProgramTranslationCache();
MG_Backend::gBackendFunctionsTable = {};
g_isInitialized = false;
#if MOBILEGL_PIPE_VERIFY
// BEFORE Close, and from here rather than from a static destructor (V1 fix round 2):
// Close() nulls the role's sink and Log.cpp's next write reopens it with "w", so the
// FATAL=0 summary the comparator used to write from __run_exit_handlers truncated the
// client half of every such run to that one line. Verify builds only - the guard is
// the compile definition, not a runtime knob, and the pull build gains no byte (G1).
MG_Pipe::MGPipeVerifyFlushSummary();
#endif
if (logLifecycle) {
MG_Util::Debug::Close();
}
+7
View File
@@ -1050,5 +1050,12 @@ namespace MobileGL::MG_Pipe {
// dereferenced, the snapshot is only ever compared). Returns false for a forwarded field,
// which has nothing to corrupt.
Bool MGPipeApplyVerifyCorruption(PipeInputs& snapshot, MGPipeInputField field);
// PipeFill.cpp. Writes the MOBILEGL_PIPE_VERIFY_FATAL=0 summary line ("N divergence(s)
// survived") NOW, while the role's log file is still open. MobileGL::Destroy calls it right
// before MG_Util::Debug::Close(): the line used to come from a namespace-scope static's
// destructor, which runs AFTER Close, and Log.cpp reopens a closed sink with "w" - so that
// summary was the only line the client half of every FATAL=0 run kept. Idempotent: a second
// call with nothing new to report, the destructor's own included, writes nothing.
void MGPipeVerifyFlushSummary();
#endif
} // namespace MobileGL::MG_Pipe
+23 -5
View File
@@ -582,12 +582,25 @@ namespace MobileGL::MG_Pipe {
Optional<MGPipeInputField> Corrupt;
String CorruptKnob; // the MOBILEGL_PIPE_VERIFY_CORRUPT value the last arm saw
std::atomic<Uint64> Divergences{0};
~VerifyState() {
Uint64 Summarised = 0; // how many of them the summary line has reported so far
// THE SUMMARY IS WRITTEN FROM MobileGL::Destroy, NOT FROM HERE (V1 fix round 2). This
// is a namespace-scope static, so this destructor runs from __run_exit_handlers, AFTER
// DestroyImpl has called MG_Util::Debug::Close(). Close nulls the role's sink; Log.cpp's
// WriteToFile then re-runs InitFile() for the next line, and InitFile opens the role's
// file with "w". So the one line this destructor wrote was the only line the client half
// of every FATAL=0 run kept - 121 bytes, the summary itself, with the entry compare's
// own reports, the arming line and the config dump gone (and the monolith arm's
// VerifyCorrupted. log wiped the same way). MGPipeVerifyFlushSummary runs before Close,
// so by the time this destructor runs there is nothing new to say and it says nothing;
// the arm is kept for a process that never called Destroy, where no Close ran and the
// line lands in the still-open file as it always did.
~VerifyState() { FlushSummary(); }
void FlushSummary() {
const Uint64 count = Divergences.load(std::memory_order_relaxed);
if (count != 0) {
MGLOG_E("MGPipe: verify summary - %llu divergence(s) survived MOBILEGL_PIPE_VERIFY_FATAL=0",
static_cast<unsigned long long>(count));
}
if (count == 0 || count == Summarised) return;
Summarised = count;
MGLOG_E("MGPipe: verify summary - %llu divergence(s) survived MOBILEGL_PIPE_VERIFY_FATAL=0",
static_cast<unsigned long long>(count));
}
};
VerifyState g_verify;
@@ -796,6 +809,11 @@ namespace MobileGL::MG_Pipe {
index0, index1);
ReportDivergence(field, "read");
}
// PipeInputs.h. The FATAL=0 summary, written while the role's log is still open:
// MobileGL::Destroy calls this right before MG_Util::Debug::Close() - see VerifyState for why
// the static destructor cannot be the writer.
void MGPipeVerifyFlushSummary() { g_verify.FlushSummary(); }
#endif // MOBILEGL_PIPE_VERIFY
// ---- push on mutation (P1 lane finding F2) ----