diff options
author | Mike Frysinger <vapier@chromium.org> | 2019-03-29 14:14:27 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@chromium.org> | 2019-03-30 03:52:15 +0000 |
commit | e2b3b80e439905ba7be9416a61b55df8da0c698f (patch) | |
tree | b8f6d6536c466c9feb0f329f14c927acc28e096d /src | |
parent | mac dump_syms: Support .dSYMs > 4GB (partially) (diff) | |
download | breakpad-e2b3b80e439905ba7be9416a61b55df8da0c698f.tar.xz |
linux_core_dumper: add explicit casts for exception fields
Some of the fields we save might have signed types depending on the
system (e.g. `typedef int pid_t`). Depending on the toolchain, we
can trip -Werror=narrowing failures like:
src/client/linux/minidump_writer/linux_core_dumper.cc:248:66: error:
narrowing conversion of ‘(__pid_t)info->siginfo_t::_sifields.siginfo_t::<anonymous union>::_kill.siginfo_t::<anonymous union>::<anonymous struct>::si_pid’
from ‘__pid_t {aka int}’ to ‘long unsigned int’ inside { } [-Werror=narrowing]
set_crash_exception_info({info->si_pid, info->si_uid});
^^^^^^
src/client/linux/minidump_writer/linux_core_dumper.cc:252:71: error:
narrowing conversion of ‘(int)info->siginfo_t::_sifields.siginfo_t::<anonymous union>::_sigsys.siginfo_t::<anonymous union>::<anonymous struct>::_syscall’
from ‘int’ to ‘long unsigned int’ inside { } [-Werror=narrowing]
set_crash_exception_info({info->si_syscall, info->si_arch});
^^^^^^^^^^
Since the exception info fields are all uint64_t which should be large
enough to handle all the fields in the siginfo_t structure, add casts
for all the assignments to avoid these errors. We have implicit casts
even without them, so we aren't changing behavior.
Bug: google-breakpad:791
Bug: chromium:945653
Change-Id: Ib04e015998f08b857159ac13e9a065a66d228d49
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1544862
Reviewed-by: Mark Mentovai <mark@chromium.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/client/linux/minidump_writer/linux_core_dumper.cc | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/client/linux/minidump_writer/linux_core_dumper.cc b/src/client/linux/minidump_writer/linux_core_dumper.cc index 3b1eabb4..41506898 100644 --- a/src/client/linux/minidump_writer/linux_core_dumper.cc +++ b/src/client/linux/minidump_writer/linux_core_dumper.cc @@ -242,14 +242,21 @@ bool LinuxCoreDumper::EnumerateThreads() { break; } - // Set crash_exception_info for common signals. + // Set crash_exception_info for common signals. Since exception info is + // unsigned, but some of these fields might be signed, we always cast. switch (info->si_signo) { case MD_EXCEPTION_CODE_LIN_SIGKILL: - set_crash_exception_info({info->si_pid, info->si_uid}); + set_crash_exception_info({ + static_cast<uint64_t>(info->si_pid), + static_cast<uint64_t>(info->si_uid), + }); break; case MD_EXCEPTION_CODE_LIN_SIGSYS: #ifdef si_syscall - set_crash_exception_info({info->si_syscall, info->si_arch}); + set_crash_exception_info({ + static_cast<uint64_t>(info->si_syscall), + static_cast<uint64_t>(info->si_arch), + }); #endif break; } |