From 57e5e28190e78465a78a79f75b0c456a2c49f608 Mon Sep 17 00:00:00 2001 From: Sergey Markelov Date: Tue, 6 Aug 2024 15:01:11 -0700 Subject: [PATCH] Fix UBSAN reported access to withing misaligned addresses This is can be an issue on ARM, it can cause a hang of CrashReportTest.MiniDump test on macOS. --- src/client/linux/minidump_writer/directory_reader.h | 5 +++-- src/client/linux/minidump_writer/linux_dumper.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/client/linux/minidump_writer/directory_reader.h b/src/client/linux/minidump_writer/directory_reader.h index 62bba8779..eb1696943 100644 --- a/src/client/linux/minidump_writer/directory_reader.h +++ b/src/client/linux/minidump_writer/directory_reader.h @@ -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 diff --git a/src/client/linux/minidump_writer/linux_dumper.h b/src/client/linux/minidump_writer/linux_dumper.h index 2d5b2e52b..75198bd4e 100644 --- a/src/client/linux/minidump_writer/linux_dumper.h +++ b/src/client/linux/minidump_writer/linux_dumper.h @@ -254,7 +254,7 @@ class LinuxDumper { // ID of the crashed thread. pid_t crash_thread_; - mutable PageAllocator allocator_; + mutable alignas(MappingInfo) PageAllocator allocator_; // IDs of all the threads. wasteful_vector threads_;