Skip to content

tests: Reduce number of threads in once test under valgrind

Philip Withnall requested to merge pwithnall/glib:fix-once-memcheck-test into main

Valgrind has a limit of 500 threads (unless you pass --max-threads to it). Running this test with more threads than that under valgrind seems unnecessary, so reduce the thread limit when valgrind support is enabled.

This should fix the following test failure:

Use --max-threads=INT to specify a larger number of threads
and rerun valgrind

valgrind: the 'impossible' happened:
   Max number of threads is too low

host stacktrace:
==5239==    at 0x580427EA: ??? (in /usr/libexec/valgrind/memcheck-amd64-linux)
==5239==    by 0x58042917: ??? (in /usr/libexec/valgrind/memcheck-amd64-linux)
==5239==    by 0x58042B80: ??? (in /usr/libexec/valgrind/memcheck-amd64-linux)
==5239==    by 0x58042BB0: ??? (in /usr/libexec/valgrind/memcheck-amd64-linux)
==5239==    by 0x58099C0E: ??? (in /usr/libexec/valgrind/memcheck-amd64-linux)
==5239==    by 0x580E6839: ??? (in /usr/libexec/valgrind/memcheck-amd64-linux)
==5239==    by 0x5809D3E9: ??? (in /usr/libexec/valgrind/memcheck-amd64-linux)
==5239==    by 0x58098DB2: ??? (in /usr/libexec/valgrind/memcheck-amd64-linux)
==5239==    by 0x5809AE97: ??? (in /usr/libexec/valgrind/memcheck-amd64-linux)
==5239==    by 0x580E40B0: ??? (in /usr/libexec/valgrind/memcheck-amd64-linux)

sched status:
  running_tid=1

Thread 1: status = VgTs_Runnable syscall 56 (lwpid 5239)
==5239==    at 0x4AB0315: clone (in /usr/lib64/libc-2.33.so)
client stack range: [0x1FFEFFB000 0x1FFF000FFF] client SP: 0x1FFEFFC468
valgrind stack range: [0x1008BAA000 0x1008CA9FFF] top usage: 8776 of 1048576

Thread 2: status = VgTs_WaitSys syscall 202 (lwpid 5268)
==5239==    at 0x4AAADDD: syscall (in /usr/lib64/libc-2.33.so)
==5239==    by 0x491E2C2: g_mutex_lock_slowpath (gthread-posix.c:1495)
==5239==    by 0x491E37C: g_mutex_lock (gthread-posix.c:1519)
==5239==    by 0x491E489: g_cond_wait (gthread-posix.c:1578)
==5239==    by 0x401436: once_thread_func (once.c:96)
==5239==    by 0x48E9F31: g_thread_proxy (gthread.c:829)
==5239==    by 0x491DE3A: linux_pthread_proxy (gthread-posix.c:1271)
==5239==    by 0x4C002A4: start_thread (in /usr/lib64/libpthread-2.33.so)
==5239==    by 0x4AB0322: clone (in /usr/lib64/libc-2.33.so)
client stack range: [0x5022000 0x5820FFF] client SP: 0x5820D28
valgrind stack range: [0x100B267000 0x100B366FFF] top usage: 3544 of 1048576

Signed-off-by: Philip Withnall pwithnall@endlessos.org

Helps: #1910 (closed)

Merge request reports