]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
drd/tests/swapcontext: Add SIGALRM handler to avoid stacktrace
authorYi Fan Yu <yifan.yu@windriver.com>
Thu, 1 Apr 2021 19:31:47 +0000 (15:31 -0400)
committerBart Van Assche <bvanassche@acm.org>
Fri, 9 Apr 2021 22:55:31 +0000 (15:55 -0700)
During testing for oe-core build on QEMU,
SIGALRM can trigger during nanosleep.
This results a different stderr output than expected.

```
==277== Process terminating with default action of signal 14 (SIGALRM)
==277==    at 0x36C74C3943: clock_nanosleep@@GLIBC_2.17 (clock_nanosleep.c:43)
==277==    by 0x36C74C8726: nanosleep (nanosleep.c:25)
```

This stacktrace printing will not occur
if we add a handler that simply exits.

https://bugs.kde.org/show_bug.cgi?id=435160

Signed-off-by: Yi Fan Yu <yifan.yu@windriver.com>
drd/tests/swapcontext.c
drd/tests/swapcontext.stderr.exp

index 622c70bc557d3a24808a82f19c07ccd4eeaa18d6..2cb969a5eafa4a55624cf34bc545f8cafc9a775a 100644 (file)
@@ -25,6 +25,10 @@ typedef struct thread_local {
   size_t nrsw;
 } thread_local_t;
 
+static void sig_alrm_handler(int signo) {
+    _exit(1);
+}
+
 static void f(void *data, int n)
 {
   enum { NR_SWITCHES = 200000 };
@@ -76,6 +80,7 @@ int main(int argc, char *argv[])
   pthread_attr_t attr;
   int i, res;
 
+  signal(SIGALRM, sig_alrm_handler);
   memset(tlocal, 0, sizeof(tlocal));
 
   pthread_attr_init(&attr);
index fcb5d5ed47782b71321f54b088883d2c70b267bc..d18786f80668a209115b4a13cf5e8afa8d9cd471 100644 (file)
@@ -1,7 +1,3 @@
 
 
-Process terminating with default action of signal 14 (SIGALRM)
-   at 0x........: swapcontext (in /...libc...)
-   by 0x........: f (swapcontext.c:?)
-
 ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)