[glib: 1/3] tests: Reduce number of threads in once test under valgrind




commit 5616e1b16e4d15221eeb1a7ca92e2d995662eaf9
Author: Philip Withnall <pwithnall endlessos org>
Date:   Tue Jun 7 09:22:56 2022 +0100

    tests: Reduce number of threads in once test under valgrind
    
    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

 glib/tests/once.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
---
diff --git a/glib/tests/once.c b/glib/tests/once.c
index ea521c05b9..4d6ddf97cf 100644
--- a/glib/tests/once.c
+++ b/glib/tests/once.c
@@ -22,8 +22,9 @@
  */
 
 #include <glib.h>
+#include "../gvalgrind.h"
 
-#if GLIB_SIZEOF_VOID_P > 4
+#if GLIB_SIZEOF_VOID_P > 4 && !defined(ENABLE_VALGRIND)
 #define THREADS 1000
 #else
 #define THREADS 100


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]