Skip to content

Commit daf7623

Browse files
committed
bt: fix unwinding zombie tasks
Zombie (and Dead) tasks no longer have a stack, and unwinding them could result in a FaultError. Report this to the user and return immediately. Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
1 parent fa216f4 commit daf7623

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

drgn_tools/bt.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,14 +411,19 @@ def bt(
411411
other functions in this module, which do not print the frames.
412412
"""
413413
task = _bt_user_friendly_arg(task_or_prog, cpu=cpu, pid=pid)
414-
traces = expand_traces(task.prog_.stack_trace(task))
415414
# We call this "task", but it's legal to provide a struct pt_regs. This
416415
# function should work fine, but not print the header, in that case.
417416
if task.type_.type_name() in (
418417
"struct task_struct",
419418
"struct task_struct *",
420419
):
420+
state = task_state_to_char(task)
421421
print_task_header(task)
422+
if state in ("Z", "X"):
423+
print(f"Task is in state: {state} - cannot unwind")
424+
return []
425+
426+
traces = expand_traces(task.prog_.stack_trace(task))
422427
print_traces(traces, show_vars=show_vars, show_absent=show_absent)
423428
frames = None
424429
if retframes:

0 commit comments

Comments
 (0)