Skip to content

[CPP]. Unaligned memory can cause a bus error on some architectures. #235

Open
@ColinLeeo

Description

@ColinLeeo

In the aarch64 architecture, atomic instructions have alignment requirements for memory addresses. If these requirements are not met, a bus error may occur.
In C++ code, most objects are created in this form:

void *buf = allocator_.alloc(sizeof(classA));
classA obj = new (buf) classA;

The allocator pre-requests a block of memory from the operating system and initializes objects within this space.This could result in some objects having an improper starting position, leading to errors when executing atomic-related instructions.

For example, some strings require a block of memory to store data. After memory is allocated for the string, the allocated pointer is located at a non-aligned address.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions