chore: print getBacktrace() after sigsegv (#1440)

This commit is contained in:
Alvaro Revuelta 2022-11-30 19:41:19 +01:00 committed by GitHub
parent fd79cbe678
commit 670035f32b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions

View File

@ -9,6 +9,7 @@ import
chronicles, chronicles,
chronos, chronos,
metrics, metrics,
libbacktrace,
system/ansi_c, system/ansi_c,
eth/keys, eth/keys,
eth/p2p/discoveryv5/enr, eth/p2p/discoveryv5/enr,
@ -709,12 +710,13 @@ when isMainModule:
# Handle SIGSEGV # Handle SIGSEGV
when defined(posix): when defined(posix):
proc handleSigsegv(signal: cint) {.noconv.} = proc handleSigsegv(signal: cint) {.noconv.} =
fatal "Shutting down after receiving SIGSEGV" # Require --debugger:native
waitFor node.stop() fatal "Shutting down after receiving SIGSEGV", stacktrace=getBacktrace()
# Only available with --stacktrace:on --linetrace:on # Not available in -d:release mode
writeStackTrace() writeStackTrace()
waitFor node.stop()
quit(QuitFailure) quit(QuitFailure)
c_signal(ansi_c.SIGSEGV, handleSigsegv) c_signal(ansi_c.SIGSEGV, handleSigsegv)