[Lldb-commits] [PATCH] D83343: [lldb/api] Add checks for StackFrame::GetRegisterContext calls (NFC)
Med Ismail Bennani via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Tue Jul 7 13:16:32 PDT 2020
mib created this revision.
mib added reviewers: teemperor, JDevlieghere.
mib added a project: LLDB.
Herald added a subscriber: lldb-commits.
This patch fixes a crash that is happening because of a null pointer
dereference in SBFrame.
StackFrame::GetRegisterContext says explicitly that you might not get
a valid RegisterContext back but the pointer wasn't tested before,
resulting in crashes. This should solve the issue.
rdar://54462095
Signed-off-by: Med Ismail Bennani <medismail.bennani at gmail.com>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D83343
Files:
lldb/source/API/SBFrame.cpp
Index: lldb/source/API/SBFrame.cpp
===================================================================
--- lldb/source/API/SBFrame.cpp
+++ lldb/source/API/SBFrame.cpp
@@ -361,9 +361,11 @@
Process::StopLocker stop_locker;
if (stop_locker.TryLock(&process->GetRunLock())) {
frame = exe_ctx.GetFramePtr();
- if (frame) {
- ret_val = frame->GetRegisterContext()->SetPC(new_pc);
- }
+ RegisterContextSP reg_ctx_sp = nullptr;
+ if (frame)
+ reg_ctx_sp = frame->GetRegisterContext();
+ if (reg_ctx_sp)
+ ret_val = reg_ctx_sp->SetPC(new_pc);
}
}
@@ -384,9 +386,11 @@
Process::StopLocker stop_locker;
if (stop_locker.TryLock(&process->GetRunLock())) {
frame = exe_ctx.GetFramePtr();
- if (frame) {
- addr = frame->GetRegisterContext()->GetSP();
- }
+ RegisterContextSP reg_ctx_sp = nullptr;
+ if (frame)
+ reg_ctx_sp = frame->GetRegisterContext();
+ if (reg_ctx_sp)
+ addr = reg_ctx_sp->GetSP();
}
}
@@ -407,8 +411,11 @@
Process::StopLocker stop_locker;
if (stop_locker.TryLock(&process->GetRunLock())) {
frame = exe_ctx.GetFramePtr();
+ RegisterContextSP reg_ctx_sp = nullptr;
if (frame)
- addr = frame->GetRegisterContext()->GetFP();
+ reg_ctx_sp = frame->GetRegisterContext();
+ if (reg_ctx_sp)
+ addr = reg_ctx_sp->GetFP();
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83343.276195.patch
Type: text/x-patch
Size: 1434 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200707/f5effd23/attachment.bin>
More information about the lldb-commits
mailing list