Skip to content

Commit

Permalink
Fix UBSAN reported access to withing misaligned addresses
Browse files Browse the repository at this point in the history
This is can be an issue on ARM, it can cause a hang of
CrashReportTest.MiniDump test on macOS.
  • Loading branch information
sergio-nsk committed Aug 7, 2024
1 parent ff38335 commit 81d5d77
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/client/linux/minidump_writer/directory_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,10 @@ class DirectoryReader {

private:
const int fd_;
bool hit_eof_;
unsigned buf_used_;
uint8_t buf_[sizeof(struct kernel_dirent) + NAME_MAX + 1];
alignas(struct kernel_dirent)
uint8_t buf_[sizeof(struct kernel_dirent) + NAME_MAX + 1];
bool hit_eof_;
};

} // namespace google_breakpad
Expand Down
3 changes: 2 additions & 1 deletion src/common/memory_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ class PageAllocator {

if (current_page_ && page_size_ - page_offset_ >= bytes) {
uint8_t* const ret = current_page_ + page_offset_;
page_offset_ += bytes;
// Keep page_offset_ aligned as the CPU natural word size.
page_offset_ += (bytes + sizeof(uintptr_t) - 1) & (~sizeof(uintptr_t) + 1);
if (page_offset_ == page_size_) {
page_offset_ = 0;
current_page_ = NULL;
Expand Down

0 comments on commit 81d5d77

Please sign in to comment.