diff --git a/lldb/source/Target/ThreadPlanStepOut.cpp b/lldb/source/Target/ThreadPlanStepOut.cpp --- a/lldb/source/Target/ThreadPlanStepOut.cpp +++ b/lldb/source/Target/ThreadPlanStepOut.cpp @@ -8,6 +8,7 @@ #include "lldb/Target/ThreadPlanStepOut.h" #include "lldb/Breakpoint/Breakpoint.h" +#include "lldb/Core/Section.h" #include "lldb/Core/Value.h" #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Symbol/Block.h" @@ -120,6 +121,21 @@ } } } + + // Perform some additional validation on the return address. + const auto return_address_section = return_address.GetSection(); + if (!return_address_section) { + LLDB_LOGF(log, "Return address had no section."); + return; + } + + const auto return_address_section_perms = + return_address_section->GetPermissions(); + if (!(return_address_section_perms & ePermissionsExecutable)) { + LLDB_LOGF(log, "Return address did not point to executable memory."); + return; + } + m_return_addr = return_address.GetLoadAddress(&m_thread.GetProcess()->GetTarget());