Skip to content

Commit e08bc32

Browse files
committed
bt: gracefully handle FaultError for variable values
There's no reason to be confident that a variable value will be valid when we're formatting it in the stack trace. It is possible that it will contain stale values that may result in FaultErrors. Be sure to catch this and simply print a message saying the FaultError happened. This ensures bt does not crash in these exceptional cases. Signed-off-by: Stephen Brennan <[email protected]>
1 parent eea7532 commit e08bc32

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

drgn_tools/bt.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,13 @@ def get_sp(frame: drgn.StackFrame) -> int:
373373
raise
374374
if val.absent_ and not show_absent:
375375
continue
376-
val_str = val.format_(dereference=False).replace("\n", "\n ")
376+
377+
try:
378+
val_str = val.format_(dereference=False).replace(
379+
"\n", "\n "
380+
)
381+
except FaultError:
382+
val_str = "(FaultError occurred while formatting!)"
377383
print(pfx + " " * 5 + f"{local} = {val_str}")
378384

379385

0 commit comments

Comments
 (0)