mirror of
https://github.com/chromium/crashpad.git
synced 2024-12-27 07:14:10 +08:00
[fuchsia] Always initialize
We occassionally see UB here that looks like context_.architecture isn't initialized. Note to reviewers: needs a test. Guidance on where/how to write one would be most welcome. Bug: fuchsia:55587 Change-Id: I886972e4d3a5c1e0c53eb17f3f65dada47a84115 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2281881 Reviewed-by: Mark Mentovai <mark@chromium.org> Reviewed-by: Scott Graham <scottmg@chromium.org> Commit-Queue: Scott Graham <scottmg@chromium.org>
This commit is contained in:
parent
e46f30cc54
commit
d2c22d6b4b
@ -54,23 +54,28 @@ void ExceptionSnapshotFuchsia::Initialize(
|
||||
codes_.push_back(exception_report.context.arch.u.arm_64.far);
|
||||
#endif
|
||||
|
||||
for (const auto& t : process_reader->Threads()) {
|
||||
if (t.id == thread_id) {
|
||||
const auto threads = process_reader->Threads();
|
||||
const auto& t =
|
||||
std::find_if(threads.begin(),
|
||||
threads.end(),
|
||||
[thread_id](const ProcessReaderFuchsia::Thread& thread) {
|
||||
return thread.id == thread_id;
|
||||
});
|
||||
if (t != threads.end()) {
|
||||
#if defined(ARCH_CPU_X86_64)
|
||||
context_.architecture = kCPUArchitectureX86_64;
|
||||
context_.x86_64 = &context_arch_;
|
||||
// TODO(fuchsia/DX-642): Add float context once saved in |t|.
|
||||
InitializeCPUContextX86_64_NoFloatingPoint(t.general_registers,
|
||||
context_.x86_64);
|
||||
context_.architecture = kCPUArchitectureX86_64;
|
||||
context_.x86_64 = &context_arch_;
|
||||
// TODO(fxbug.dev/5496): Add float context once saved in |t|.
|
||||
InitializeCPUContextX86_64_NoFloatingPoint(t->general_registers,
|
||||
context_.x86_64);
|
||||
#elif defined(ARCH_CPU_ARM64)
|
||||
context_.architecture = kCPUArchitectureARM64;
|
||||
context_.arm64 = &context_arch_;
|
||||
InitializeCPUContextARM64(
|
||||
t.general_registers, t.vector_registers, context_.arm64);
|
||||
context_.architecture = kCPUArchitectureARM64;
|
||||
context_.arm64 = &context_arch_;
|
||||
InitializeCPUContextARM64(
|
||||
t->general_registers, t->vector_registers, context_.arm64);
|
||||
#else
|
||||
#error Port.
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (context_.InstructionPointer() != 0 &&
|
||||
@ -83,6 +88,8 @@ void ExceptionSnapshotFuchsia::Initialize(
|
||||
exception_address_ = exception_report.context.arch.u.x86_64.cr2;
|
||||
#elif defined(ARCH_CPU_ARM64)
|
||||
exception_address_ = exception_report.context.arch.u.arm_64.far;
|
||||
#else
|
||||
#error Port.
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ class ExceptionSnapshotFuchsia final : public ExceptionSnapshot {
|
||||
#elif defined(ARCH_CPU_ARM64)
|
||||
CPUContextARM64 context_arch_;
|
||||
#endif
|
||||
CPUContext context_;
|
||||
CPUContext context_ = {};
|
||||
std::vector<uint64_t> codes_;
|
||||
zx_koid_t thread_id_;
|
||||
zx_vaddr_t exception_address_;
|
||||
|
Loading…
x
Reference in New Issue
Block a user