Skip to content

Conversation

pmhahn
Copy link

@pmhahn pmhahn commented Mar 24, 2025

Calling trace_pop_target() invalidates the linked list of target_stack_node_ts by free()ing the node and its p_target.

But p_stack_top may still points at that now freed node. Entering the debugger will crash as it will start from p_stack_top.

  1. Explicitly invalidate p_target by setting it to NULL.
  2. Explicitly pop the top node from p_stack_top before calling trace_pop_target().

Closes: #158
Fixes: a86f3c0 ("trace: fix SIGSEGV after pop")

Calling `trace_pop_target()` invalidates the linked list of
`target_stack_node_t`s by `free()`ing the node and its `p_target`.

But `p_stack_top` may still points at that now freed node. Entering the
debugger will crash as it will start from `p_stack_top`.

1. Explicitly invalidate `p_target` by setting it to `NULL`.
2. Explicitly pop the top node from `p_stack_top` before calling
   `trace_pop_target()`.

Closes: Trepan-Debuggers#158
Fixes: a86f3c0 ("trace: fix SIGSEGV after pop")
Signed-off-by: Philipp Hahn <[email protected]>
@rocky
Copy link
Collaborator

rocky commented Mar 24, 2025

Seems a little hacky, but ok.

@rocky rocky merged commit d68af0c into Trepan-Debuggers:remake-4-3 Mar 24, 2025
1 check passed
@pmhahn pmhahn deleted the sigsegv branch March 24, 2025 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Entering debugger crashes
2 participants