Skip to content

Commit 7accbab

Browse files
authored
Merge pull request #9184 from jasonmolenda/cp/r134391577-limit-assembly-instruciton-scan2
[lldb] Don't scan more than 10MB of assembly insns (llvm#105890)
2 parents fd36d4b + a1bcbf7 commit 7accbab

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lldb/source/Symbol/FuncUnwinders.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,12 +334,22 @@ UnwindPlanSP FuncUnwinders::GetAssemblyUnwindPlan(Target &target,
334334

335335
m_tried_unwind_plan_assembly = true;
336336

337+
// Don't analyze more than 10 megabytes of instructions,
338+
// if a function is legitimately larger than that, we'll
339+
// miss the epilogue instructions, but guard against a
340+
// bogusly large function and analyzing large amounts of
341+
// non-instruction data.
342+
AddressRange range = m_range;
343+
const addr_t func_size =
344+
std::min(range.GetByteSize(), (addr_t)1024 * 10 * 10);
345+
range.SetByteSize(func_size);
346+
337347
UnwindAssemblySP assembly_profiler_sp(GetUnwindAssemblyProfiler(target));
338348
if (assembly_profiler_sp) {
339349
m_unwind_plan_assembly_sp =
340350
std::make_shared<UnwindPlan>(lldb::eRegisterKindGeneric);
341351
if (!assembly_profiler_sp->GetNonCallSiteUnwindPlanFromAssembly(
342-
m_range, thread, *m_unwind_plan_assembly_sp)) {
352+
range, thread, *m_unwind_plan_assembly_sp)) {
343353
m_unwind_plan_assembly_sp.reset();
344354
}
345355
}

0 commit comments

Comments
 (0)