summaryrefslogtreecommitdiff
path: root/external
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2021-10-26 23:01:48 +0200
committerStephan Bergmann <sbergman@redhat.com>2021-10-27 07:38:56 +0200
commit11ecb45eb922037082feda3fabd8d0eed3e3ffb0 (patch)
tree1408a8341ff44de27076f23e9073e713ab6f2574 /external
parent092f61bd3b1fbffd40988aa7f55f447d3d877cbe (diff)
external/breakpad: Silence some UBSan warnings
...which I happened to run into when the breakpad code kicked in due to some crash happening, > src/client/linux/minidump_writer/minidump_writer.cc:721:12: runtime error: null pointer passed as argument 2, which is declared to never be null /usr/include/string.h:44:28: note: nonnull attribute specified here > src/client/linux/minidump_writer/minidump_writer.cc:763:14: runtime error: applying non-zero offset to non-null pointer 0x000000200000 produced null pointer > src/client/linux/minidump_writer/minidump_writer.cc:772:64: runtime error: applying non-zero offset 3200848 to null pointer (Unlike the changes in the existing external/breakpad/ubsan.patch, which is only applied when doing sanitizer builds, these changes should be non-controversial and OK to apply always, so they go into a different patch file.) Change-Id: Ib1b3f87ba22f96d5fb93b8fcb9951ddc3c353697 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124245 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'external')
-rw-r--r--external/breakpad/UnpackedTarball_breakpad.mk1
-rw-r--r--external/breakpad/sanitizer.patch29
2 files changed, 30 insertions, 0 deletions
diff --git a/external/breakpad/UnpackedTarball_breakpad.mk b/external/breakpad/UnpackedTarball_breakpad.mk
index 994a87fcd95a..9a10a5ac1abb 100644
--- a/external/breakpad/UnpackedTarball_breakpad.mk
+++ b/external/breakpad/UnpackedTarball_breakpad.mk
@@ -28,6 +28,7 @@ $(eval $(call gb_UnpackedTarball_add_patches,breakpad,\
external/breakpad/breakpad-dump_syms.patch.1 \
external/breakpad/breakpad-no-env.patch.1 \
external/breakpad/SIGSTKSZ.patch \
+ external/breakpad/sanitizer.patch \
))
$(eval $(call gb_UnpackedTarball_add_files,breakpad,src/tools/windows/dump_syms,\
diff --git a/external/breakpad/sanitizer.patch b/external/breakpad/sanitizer.patch
new file mode 100644
index 000000000000..5d673103d95b
--- /dev/null
+++ b/external/breakpad/sanitizer.patch
@@ -0,0 +1,29 @@
+--- src/client/linux/minidump_writer/minidump_writer.cc
++++ src/client/linux/minidump_writer/minidump_writer.cc
+@@ -717,7 +717,7 @@
+ const std::vector<uint64_t> crash_exception_info =
+ dumper_->crash_exception_info();
+ stream->exception_record.number_parameters = crash_exception_info.size();
+- memcpy(stream->exception_record.exception_information,
++ if (!crash_exception_info.empty()) memcpy(stream->exception_record.exception_information,
+ crash_exception_info.data(),
+ sizeof(uint64_t) * crash_exception_info.size());
+ stream->thread_context = crashing_thread_context_;
+@@ -760,7 +760,7 @@
+ // Adjust base address with the virtual address of the PT_LOAD segment
+ // corresponding to offset 0
+ if (ph.p_type == PT_LOAD && ph.p_offset == 0) {
+- base -= ph.p_vaddr;
++ base = reinterpret_cast<char*>(reinterpret_cast<uintptr_t>(base) - ph.p_vaddr);
+ }
+ if (ph.p_type == PT_DYNAMIC) {
+ dyn_addr = ph.p_vaddr;
+@@ -769,7 +769,7 @@
+ if (!dyn_addr)
+ return false;
+
+- ElfW(Dyn)* dynamic = reinterpret_cast<ElfW(Dyn)*>(dyn_addr + base);
++ ElfW(Dyn)* dynamic = reinterpret_cast<ElfW(Dyn)*>(dyn_addr + reinterpret_cast<uintptr_t>(base));
+
+ // The dynamic linker makes information available that helps gdb find all
+ // DSOs loaded into the program. If this information is indeed available,