apache / apache/tsfile

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

Open
#235 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
203
Forks
104
Avg merge
2d 6h
Merged PRs (30d)
33

Description

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:
```c++
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.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing the allocator_ path that reserves memory and places C++ objects, focusing on the alignment requirements of atomic instructions on aarch64. Reproduce or validate the unaligned allocation case on that architecture; done means allocated object addresses meet the required alignment and no bus error occurs.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.