[Fix] (MGPipe, MG_Remote): verify server pack state and reject records after guilty GPU resets

This commit is contained in:
2026-10-05 02:51:19 -04:00
parent c5d25868cf
commit f5b8fe48aa
6 changed files with 65 additions and 108 deletions
+5
View File
@@ -1095,6 +1095,10 @@ namespace MobileGL::MG_Remote::Server {
bool corrupt = false;
const bool popped = consumer.ApplyOne(
[this, &applier, timed](const Transport::RingRecordView& record) {
// Check after acquiring each record: a producer may publish more work
// while this drain is running, after the outer-loop reset check.
if (m_backend != nullptr && m_backend->LatchIfGpuFaulted()) return false;
if (SessionLatched()) return false;
// P65ServerFrame: timed around the ONE call that is the server's work, and
// summed across the drains a frame spans. See the block above DrainRing's loop.
// Only when the line is on: two clock reads per record were a measurable part
@@ -1162,6 +1166,7 @@ namespace MobileGL::MG_Remote::Server {
// DrainedRecords() one behind appliedSeq on 1 run in ~40 under `-j 8`.
// Per-record, before the publish, it can never be behind.
m_drained.fetch_add(1, std::memory_order_acq_rel);
return true;
},
&corrupt);
if (corrupt) {
+9 -1
View File
@@ -73,6 +73,7 @@
#include <atomic>
#include <cstdint>
#include <type_traits>
namespace MobileGL::MG_Remote::Transport {
@@ -462,7 +463,14 @@ namespace MobileGL::MG_Remote::Transport {
if (!m_cmd->Pop(view, outCorrupt)) {
return false;
}
apply(view);
// A terminal rejection after Pop must not acknowledge an unapplied record.
// A bool callback returning false ends this consumer's session; it cannot retry
// the popped record. Existing void callbacks retain their original semantics.
if constexpr (std::is_same_v<std::invoke_result_t<Apply, const RingRecordView&>, bool>) {
if (!apply(view)) return false;
} else {
apply(view);
}
++m_appliedSeq;
Watermark::AdvanceApplied(*m_control, m_appliedSeq);
m_cmd->PublishApplied();