Skip to content

bugfix(gamememory): Align memory pool allocations to 8 bytes - #637

Open
tintinhamans wants to merge 1 commit into
GeneralsOnlineDevelopmentTeam:mainfrom
tintinhamans:arctic/go/fix/memory-alignment-8
Open

tintinhamans wants to merge 1 commit into
GeneralsOnlineDevelopmentTeam:mainfrom
tintinhamans:arctic/go/fix/memory-alignment-8

Conversation

@tintinhamans

@tintinhamans tintinhamans commented Oct 15, 2026 •

Copy link
Copy Markdown

Cherry-pick of TheSuperHackers#3609, merged upstream, with the same change on the Generals half.

The memory pools return pointers that are 4 mod 8 about half the time, while MSVC promises 8 on x86. protobuf keeps flags in the low bits of its heap pointers, so on our heap it freed a pointer 4 bytes early and crashed GNS, which is linked into the exe.

MEM_BOUND_ALIGNMENT is now 8 and the block header is padded to a multiple of 8. Debug builds assert the alignment. It costs about 4.5 MB (~8%) of initial pool memory on Zero Hour, and nothing in the simulation orders or hashes by pointer.

@tintinhamans
tintinhamans force-pushed the arctic/go/fix/memory-alignment-8 branch from e6f83b5 to bf35dfb Compare November 4, 2026 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant