Skip to content

Commit d9b0a79

Browse files
committed
profiling(Gecko): check if thread list is not empty before accessing it
It seems to sometimes happen that some samples (possibly at the very start / end) do not have any active threads in the interpreter state. It is OK to make main_tid maybe None here, since if it is, the threads list is empty, and so the for loop will not execute anyways. Signed-off-by: Sofia Donato Ferreira <flowlnlnln@gmail.com>
1 parent 8920f2f commit d9b0a79

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Lib/profiling/sampling/gecko_collector.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ def collect(self, stack_frames, timestamps_us=None):
173173
for interpreter_info in stack_frames:
174174
# Since 'threads' is in order from newest to oldest,
175175
# we know the first thread must be the main thread.
176-
main_tid = interpreter_info.threads[-1].thread_id
176+
main_tid = None
177+
if len(interpreter_info.threads) != 0:
178+
main_tid = interpreter_info.threads[-1].thread_id
177179
for thread_info in interpreter_info.threads:
178180
frames = filter_internal_frames(thread_info.frame_info)
179181
tid = thread_info.thread_id

0 commit comments

Comments
 (0)