Skip to content

Commit e9eb22e

Browse files
authored
Merge pull request #285 from mattip/dead-thread-test
create fewer threads but still test the problem
2 parents 46306f7 + d1a12da commit e9eb22e

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

‎vmprof/test/test_run.py‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -353,19 +353,20 @@ def test_vmprof_real_time_many_threads():
353353
def test_vmprof_real_time_threads_exit():
354354
# Registered threads that exit while profiling goes on used to leave
355355
# stale pthread ids in the list, and forwarding SIGALRM to one of them
356-
# segfaulted.
356+
# segfaulted. Enough threads that glibc unmaps some of their stacks
357+
# instead of caching them, and a slow timer: sampling threads while
358+
# they start or exit at a high rate hits a different, older problem.
357359
import threading
358360
prof = vmprof.Profiler()
359-
with prof.measure(period=0.001, real_time=True):
360-
for _ in range(5):
361-
threads = [threading.Thread(target=functime_foo, args=[0.01, True])
362-
for _ in range(20)]
363-
for thread in threads:
364-
thread.start()
365-
for thread in threads:
366-
thread.join()
367-
# keep forwarding signals now that all of them are gone
368-
functime_bar(0.1)
361+
with prof.measure(period=0.01, real_time=True):
362+
threads = [threading.Thread(target=functime_foo, args=[0.05, True])
363+
for _ in range(20)]
364+
for thread in threads:
365+
thread.start()
366+
for thread in threads:
367+
thread.join()
368+
# keep forwarding signals now that all of them are gone
369+
functime_bar(0.3)
369370
stats = prof.get_stats()
370371
d = dict(stats.top_profile())
371372
assert foo_time_name in d

0 commit comments

Comments
 (0)