Skip to content

Commit

Permalink
Find crash thread before stacktrace is normalized
Browse files Browse the repository at this point in the history
When we normalize a stacktrace, we sometimes remove certain
frames. The problem is when crash frame is one of those
removed frames. In such cases, we simply cannot (reliably)
find the crash thread.

Therefore, before we normalize the stacktrace, we look
for the crash thread and remember its id. We can then
use that id later, if needed.

Related: rhbz#2168223
Fixes: #337

Signed-off-by: Michal Srb <[email protected]>
  • Loading branch information
msrb authored and mgrabovsky committed Mar 1, 2023
1 parent a649a68 commit 755650d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/normalize.c
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,20 @@ sr_normalize_core_thread(struct sr_core_thread *thread)
void
sr_normalize_gdb_stacktrace(struct sr_gdb_stacktrace *stacktrace)
{

if (stacktrace->crash_tid == UINT32_MAX)
{
// We don't have the crash thread id yet and it will be more
// difficult to find the crach thread once we normalize the stacktrace.
// So let's just look for it now and remember it.
struct sr_gdb_thread *crash_thread;
crash_thread = sr_gdb_stacktrace_find_crash_thread(stacktrace);
if (crash_thread)
{
stacktrace->crash_tid = crash_thread->tid;
}
}

struct sr_gdb_thread *thread = stacktrace->threads;
while (thread)
{
Expand Down
1 change: 1 addition & 0 deletions python/py_gdb_stacktrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ sr_py_gdb_stacktrace_normalize(PyObject *self, PyObject *args)

this->stacktrace->threads = tmp->threads;
this->stacktrace->crash = tmp->crash;
this->stacktrace->crash_tid = tmp->crash_tid;
tmp->threads = NULL;
tmp->crash = NULL;
sr_gdb_stacktrace_free(tmp);
Expand Down

0 comments on commit 755650d

Please sign in to comment.