diff mbox series

[kvm-unit-tests,v2,1/3] pretty_print_stacks: prevent invalid address arguments

Message ID 20230404185048.2824384-2-nsg@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series Improve stack pretty printing | expand

Commit Message

Nina Schoetterl-Glausch April 4, 2023, 6:50 p.m. UTC
If a return address is zero, the script will pass -1 to addr2line which
it considers an invalid flag.
Zero is an unlikely return address, but we might see it, for example
because the backtrace is unreliable on s390x if there is an interrupt
frame on the stack.

Fixes: a9143a24 ("scripts: pretty print stack traces")
Tested-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
---
 scripts/pretty_print_stacks.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/scripts/pretty_print_stacks.py b/scripts/pretty_print_stacks.py
index 1e59cde6..ba6f0825 100755
--- a/scripts/pretty_print_stacks.py
+++ b/scripts/pretty_print_stacks.py
@@ -22,7 +22,7 @@  def pretty_print_stack(binary, line):
         if addr.startswith('@'):
             addrs[i] = addr[1:]
         else:
-            addrs[i] = '%lx' % (int(addrs[i], 16) - 1)
+            addrs[i] = '%lx' % max((int(addrs[i], 16) - 1), 0)
 
     # Output like this:
     #        0x004002be: start64 at path/to/kvm-unit-tests/x86/cstart64.S:208