From aa4bb50b1ee0d89c9efb7fa7b4e4c6406afaf5c1 Mon Sep 17 00:00:00 2001 From: "Masih H. Derkani" Date: Thu, 18 Dec 2025 16:46:01 +0000 Subject: [PATCH] Log the panic callstack for debugging purposes (#2632) When a non-upgrade panic is caught during `ProcessBlock` fetch the call stack and log it. Because, without it debugging is much more difficult. (cherry picked from commit 9f1994232393c89c500a5e12766b469507ba2c3f) --- app/app.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/app.go b/app/app.go index 7a06371f20..623a08c8ca 100644 --- a/app/app.go +++ b/app/app.go @@ -12,6 +12,7 @@ import ( "os" "path/filepath" "regexp" + "runtime/debug" "strings" "sync" "time" @@ -1399,12 +1400,14 @@ func (app *App) ProcessBlock(ctx sdk.Context, txs [][]byte, req BlockProcessRequ defer func() { if r := recover(); r != nil { panicMsg := fmt.Sprintf("%v", r) + // Re-panic for upgrade-related panics to allow proper upgrade mechanism if upgradePanicRe.MatchString(panicMsg) { ctx.Logger().Error("upgrade panic detected, panicking to trigger upgrade", "panic", r) panic(r) // Re-panic to trigger upgrade mechanism } - ctx.Logger().Error("panic recovered in ProcessBlock", "panic", r) + stack := string(debug.Stack()) + ctx.Logger().Error("panic recovered in ProcessBlock", "panic", r, "stack", stack) err = fmt.Errorf("ProcessBlock panic: %v", r) events = nil txResults = nil