Clarified meaning of process_state.requesting_thread

(the now-removed 'treat as pid' was hallunicated by the bot; the
taken-from-sentry version missed the guard against -1)

> The index of the thread that requested a dump be written in the
> threads vector. [..] If the dump was not produced as a result of an exception
> [..] this field will be set to -1,
This commit is contained in:
Klaas van Schelven
2025-11-12 21:33:18 +01:00
parent 54ec6eaceb
commit eea5f032e2
2 changed files with 21 additions and 25 deletions

View File

@@ -88,7 +88,7 @@ def _find_module_for_address(process_state, abs_addr: int):
def event_threads_for_process_state(process_state):
threads = []
for thread in process_state.threads():
for thread_index, thread in enumerate(process_state.threads()):
thread_frames = []
for frame in thread.frames():
@@ -136,7 +136,7 @@ def event_threads_for_process_state(process_state):
threads.append({
"id": thread.thread_id,
"crashed": (thread.thread_id == process_state.requesting_thread),
"crashed": thread_index == process_state.requesting_thread,
"stacktrace": {"frames": thread_frames},
})

View File

@@ -29,34 +29,30 @@ def merge_minidump_event(data, minidump_bytes):
threads = event_threads_for_process_state(process_state)
data.setdefault("threads", {})["values"] = threads
# Mark the crashed thread and add its stacktrace to the exception
crashed_thread = threads[process_state.requesting_thread]
crashed_thread['crashed'] = True
if process_state.requesting_thread > -1:
crashed_thread = threads[process_state.requesting_thread]
exception_value = 'Assertion Error: %s' % process_state.assertion if process_state.assertion \
else 'Fatal Error: %s' %process_state.crash_reason
exception_value = 'Assertion Error: %s' % process_state.assertion if process_state.assertion \
else 'Fatal Error: %s' % process_state.crash_reason
# Extract the crash reason and infos
exception = {
'value': exception_value,
'thread_id': crashed_thread['id'],
'type': process_state.crash_reason,
exception = {
'value': exception_value,
'thread_id': crashed_thread['id'],
'type': process_state.crash_reason,
'stacktrace': crashed_thread.pop('stacktrace'),
'value': exception_value,
}
# Move stacktrace here from crashed_thread (mutating!)
'stacktrace': crashed_thread.pop('stacktrace'),
'value': exception_value,
}
for frame in exception['stacktrace']['frames']:
frame['in_app'] = True # minidumps don't distinguish in_app frames; assume all are in_app
for frame in exception['stacktrace']['frames']:
frame['in_app'] = True # minidumps don't distinguish in_app frames; assume all are in_app
exception['stacktrace']['frames'].reverse() # "Frames should be sorted from oldest to newest."
# TODO we don't have display-info for threads yet, I think?
# we may need to revert the per-thread stacktraces above as well then
exception['stacktrace']['frames'].reverse() # "Frames should be sorted from oldest to newest."
# TODO we don't have display-info for threads yet, I think?
# we may need to revert the per-thread stacktraces above as well then
data.setdefault('exception', {}) \
.setdefault('values', []) \
.append(exception)
data.setdefault('exception', {}) \
.setdefault('values', []) \
.append(exception)
# Extract referenced (not all loaded) images
images = [{