Repository navigation
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review: 2
Please check the settings in the CodeRabbit UI or the
|
Segfaultd
force-pushed
the
refactor/modern-memory-2-allocator
branch
from
November 16, 2026 11:43
78f100e to
39465ca
Compare
Delete memory_override.h/.cpp and alloca.h together with the SetMalloc/ SetFree/SetRealloc hook API, UseRaknetFixedHeap and the _USE_RAK_MEMORY_OVERRIDE, _LINK_DL_MALLOC, USE_ALLOCA and MAX_ALLOCA_STACK_ALLOCATION defines. Headers now include only what they use. alloca sites (reliability layer split, string compressor, file list, peer send list, profanity filter) use std::vector / std::string. Rewrite the custom memory management page: replace global operator new/delete or link a malloc replacement.
… with shared_ptr Owned-buffer APIs now fill std::unique_ptr<unsigned char[]> (allocated with new[], matching the deleter): - BitStream::CopyData(std::unique_ptr<unsigned char[]> &) replaces the unsigned char ** overload; an empty stream yields null and returns 0 instead of asserting - BitStream::ReadAlignedBytesSafeAlloc (both int/unsigned overloads) - DataCompressor::DecompressAndAllocate - HuffmanEncodingTree::CharacterEncoding::encoding (internal owner of the CopyData result) Callers updated: HuffmanEncodingTree, TableSerializer (the Table cell keeps its own malloc'd copy via Cell::Set), bit_stream fuzzer, BitStreamBounds test. RakNetSmartPtr (smart_ptr.h) is deleted; Lobby2 BinaryDataBlock handles use std::shared_ptr. Not converted: ReliabilityLayer::Receive (internal, feeds Packet::data), CloudAllocator callbacks, Get*OfflinePingResponse/GetSessionConfig (non-owning views).
DecompressAndAllocate checks every read, rejects payloads longer than the stream and declared sizes above the payload bit count (each decoded byte costs at least one bit), and never asserts on network data. Restores the CRLF line endings the previous commit converted to LF in seven files.
A ReliabilityLayer that was never given SetSplitMessageProgressInterval read the interval uninitialised. Where the memory held a small nonzero value, the receiver emitted ID_DOWNLOAD_PROGRESS while reassembling a split message and handed it out ahead of the message itself: ReassemblesMessageOfTensOfThousandsOfFragments then took a 1353-byte progress message for its 32 MiB message on the macOS runner. The new test builds the layer over memory holding 1 in every word.
Segfaultd
force-pushed
the
refactor/modern-memory-2-allocator
branch
from
November 16, 2026 13:58
39465ca to
d622b2d
Compare
Segfaultd
force-pushed
the
refactor/modern-memory-1-safety-net
branch
from
November 16, 2026 13:58
efb84bf to
7464dfd
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Removes the custom allocator layer entirely:
rakMalloc/rakFree/rakRealloc,OP_NEW/OP_DELETE,memory_override.h,alloca, and the_FILE_AND_LINE_allocation-tracking arguments on the allocation paths. Allocation is now plainnew/std::make_unique/std::vector, with ownership moved into smart pointers where it was manual.DataCompressor::DecompressAndAllocatenow rejects an unbounded size taken from the network instead of allocating itRakPeer::GetLiveRemoteSystemIndexEntriesForTesting()(test-only) replaces therakMallochook counting in master'sRemoteSystemLookupTests; the converted test still fails when the leak is put backBreaking
Applications that installed custom allocators through
rakMalloc_Exand friends, or calledOP_NEW/OP_DELETE, must use standard allocation. See the migration guide in 6/6.Notes
rakMallocblocks don't grow between waves. That hook no longer exists, and the remainingoperator newcheck is coarser. The unit test above is now the precise guard for that leak; LeakSanitizer covers the rest.Test plan
-Werrorbuild; unit tests plus the Reliability/Simulated/RakPeer/Encrypt/Mtu/Split integration testsCommits
Stack, merge in order: 1/6 safety net, 2/6 allocator, 3/6 core transport, 4/6 plugins, 5/6 Table + extensions, 6/6 delete DataStructures. Each PR targets the branch of the one before it. Breaking change for the next major version; no version bump yet.