From 0107032db9adcf8a9ed58aec77909dcf58124114 Mon Sep 17 00:00:00 2001 From: sadiq1971 Date: Tue, 11 Mar 2025 00:18:26 +0600 Subject: [PATCH] fix: added safegurd to protect infinite stack trace --- common/entrypoint.go | 10 +++++++--- common/stack_tracer.go | 3 +++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/common/entrypoint.go b/common/entrypoint.go index c2ac005..8d4da81 100644 --- a/common/entrypoint.go +++ b/common/entrypoint.go @@ -24,8 +24,9 @@ func ProgramEntrypoint(arch string) func(function string) bool { function == "runtime.systemstack" || function == "runtime.gopanic" || function == "runtime.chanrecv" || - function == "runtime.startm" || // 32 bit specific - function == "runtime.sysAlloc" // // 32 bit specific + function == "runtime.startm" || + function == "runtime.sysAlloc" || + function == "runtime.chansend" } case "mips64": return func(function string) bool { @@ -40,7 +41,10 @@ func ProgramEntrypoint(arch string) func(function string) bool { function == "runtime.morestack" || function == "runtime.systemstack" || function == "runtime.gopanic" || - function == "runtime.chanrecv" + function == "runtime.chanrecv" || + function == "runtime.startm" || + function == "runtime.sysAlloc" || + function == "runtime.chansend" } } return func(function string) bool { diff --git a/common/stack_tracer.go b/common/stack_tracer.go index d96b4c1..bf42ab7 100644 --- a/common/stack_tracer.go +++ b/common/stack_tracer.go @@ -91,6 +91,9 @@ func TraceAllAsmCaller( var visit func(segment asmparser.Segment) visit = func(segment asmparser.Segment) { + if len(sources) >= 20 { // protect for infinite searching + return + } if seen[segment] { return }