Repository navigation
fix: prevent worldserver crash when saving oversized arena replays - #26
Conversation
saveReplay serializes every recorded packet of a match into a single ByteBuffer. A long match (or one heavy on SMSG_UPDATE_OBJECT) accumulates enough data to push the buffer past ByteBuffer's hard 10,000,000-byte ASSERT in append(), which calls Crash() and takes down the worldserver at the end of the arena. Guard the serialization loop: stop appending on a packet boundary once the buffer would reach the limit, so the stream stays well-framed for playback and the replay is truncated instead of crashing the server. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
ChangesReplay serialization buffer cap
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Problem
ArenaReplayBGScript::saveReplayserializes every recorded packet of a match into a singleArenaReplayByteBuffer. A long match (or one heavy onSMSG_UPDATE_OBJECT, which is in the watch list) accumulates enough data to push that buffer past the core's hard 10,000,000-byte sanity check inByteBuffer::append:Acore::AssertcallsCrash(), so the entire worldserver goes down at the end of the arena. Observed in the wild with a recording of ~190k packets:The DOT tick / kill that ends the match in the trace is incidental; any arena ending with a large enough recording crashes the same way.
Fix
Guard the serialization loop. Before each append, check whether writing the next packet (10-byte header + body) would reach the limit, and if so stop on the current packet boundary. Because the break happens between whole packets, the written stream stays well-framed and replays back correctly via the existing
headerSize / timestamp / opcodereader. The replay is truncated instead of crashing the server.A
LOG_WARNrecords when truncation happens so oversized recordings are visible. Limit set to 9,000,000 to leave headroom under the 10 MB cap.Notes / follow-ups
SMSG_UPDATE_OBJECTin the watch list. Trimming it would shrink recordings substantially, at a fidelity cost; left for separate discussion.Summary by CodeRabbit