Skip to content

Make sure pointers and alignments are 64-bits - #49

Open
illwieckz wants to merge 2 commits into
masterfrom
illwieckz/64bit
Open

illwieckz wants to merge 2 commits into
masterfrom
illwieckz/64bit

Conversation

@illwieckz

Copy link
Copy Markdown
Member

This is very minor and similar to:

Except #46 only focused on what is built in the Dæmon engine.

This makes sure 64-bit pointers and alignments are 64-bits explicitly and don't rely on luck.

While running 32-bit code in virtual machine game code can still find usefulness in possible future distributed product (for example if one day breakpad supports Wasm or LFI), running the minidump processor as 32-bit is far less needed.

What's precious in this is that not only 32-bit hosts are less forgiving on lazy size assumptions and can be useful to enforce strictness, it happens that in the special case of Breakpad this has been the only reliable way for me to track done that thread problem:

So I think I'll keep the linux-i686 platform in the CI to help catch the reintroduction of such hard-to-reproduce bugs, with the extra benefit of lazy pointer or alignment assumptions like those ones being caught.

In the end, these patches are required to improve reliability in testing #48 being fixed or not, while #48 can affect every platform.

None of this broke any other platform, it has been tested in CI and outside CI on:

  • Linux amd64 GCC
  • Linux i686 GCC
  • Linux arm64 GCC
  • Linux amd64 Clang
  • Windows amd64 MinGW
  • macOS amd64 AppleClang
  • macOS arm64 AppleClang
  • FreeBSD amd64 Clang

This is picked from:

Use the value type for the alignment mask to prevent
truncation of 64-bit values on 32-bit targets.
Use uint64_t instead of size_t for raw exception addresses, since
size_t is only as wide as the host's address space. This avoids
truncating 64-bit addresses when processing 64-bit minidumps on
32-bit hosts.
@illwieckz illwieckz changed the title Make sure 64-bit pointers and alignements are 64-bits Make sure pointers and alignments are 64-bits Oct 16, 2026
@slipher

slipher commented Oct 16, 2026

Copy link
Copy Markdown
Member

src/processor/minidump_processor: preserve 64-bit exception addresses: LGTM
src/common/memory_allocator: preserve 64-bit alignment masks: Not useful.

static T AlignUp(T offset, size_t alignment) {
assert(alignment > 0 && ((alignment - 1) & alignment) == 0);
return (offset + (alignment - 1)) & ~(alignment - 1);
const T mask = static_cast<T>(alignment - 1);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change doesn't change the semantics of the code at all. It just factors out a common subexpression without changing its type.

If there were really an issue due to passing in an alignment larger than 2^32, you'd have to change the type of the function argument. But a 32-bit process can't allocate more than 2^32 so that doesn't makes sense and can't happen.

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.

2 participants