Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame^] | 1 | From 4c8c4a9c3a92300e3e6500e5a278ca37514a1fdb Mon Sep 17 00:00:00 2001 |
| 2 | From: Yi Fan Yu <yifan.yu@windriver.com> |
| 3 | Date: Thu, 1 Apr 2021 15:31:47 -0400 |
| 4 | Subject: [PATCH] drd/tests/swapcontext: Add SIGALRM handler to avoid |
| 5 | stacktrace |
| 6 | |
| 7 | During testing for oe-core build on QEMU, |
| 8 | SIGALRM can trigger during nanosleep. |
| 9 | This results a different stderr output than expected. |
| 10 | |
| 11 | ``` |
| 12 | ==277== Process terminating with default action of signal 14 (SIGALRM) |
| 13 | ==277== at 0x36C74C3943: clock_nanosleep@@GLIBC_2.17 (clock_nanosleep.c:43) |
| 14 | ==277== by 0x36C74C8726: nanosleep (nanosleep.c:25) |
| 15 | ``` |
| 16 | |
| 17 | This stacktrace printing will not occur |
| 18 | if we add a handler that simply exits. |
| 19 | |
| 20 | https://bugs.kde.org/show_bug.cgi?id=435160 |
| 21 | |
| 22 | Signed-off-by: Yi Fan Yu <yifan.yu@windriver.com> |
| 23 | --- |
| 24 | drd/tests/swapcontext.c | 5 +++++ |
| 25 | drd/tests/swapcontext.stderr.exp | 4 ---- |
| 26 | 2 files changed, 5 insertions(+), 4 deletions(-) |
| 27 | |
| 28 | diff --git a/drd/tests/swapcontext.c b/drd/tests/swapcontext.c |
| 29 | index 622c70bc5..2cb969a5e 100644 |
| 30 | --- a/drd/tests/swapcontext.c |
| 31 | +++ b/drd/tests/swapcontext.c |
| 32 | @@ -25,6 +25,10 @@ typedef struct thread_local { |
| 33 | size_t nrsw; |
| 34 | } thread_local_t; |
| 35 | |
| 36 | +static void sig_alrm_handler(int signo) { |
| 37 | + _exit(1); |
| 38 | +} |
| 39 | + |
| 40 | static void f(void *data, int n) |
| 41 | { |
| 42 | enum { NR_SWITCHES = 200000 }; |
| 43 | @@ -76,6 +80,7 @@ int main(int argc, char *argv[]) |
| 44 | pthread_attr_t attr; |
| 45 | int i, res; |
| 46 | |
| 47 | + signal(SIGALRM, sig_alrm_handler); |
| 48 | memset(tlocal, 0, sizeof(tlocal)); |
| 49 | |
| 50 | pthread_attr_init(&attr); |
| 51 | diff --git a/drd/tests/swapcontext.stderr.exp b/drd/tests/swapcontext.stderr.exp |
| 52 | index fcb5d5ed4..d18786f80 100644 |
| 53 | --- a/drd/tests/swapcontext.stderr.exp |
| 54 | +++ b/drd/tests/swapcontext.stderr.exp |
| 55 | @@ -1,7 +1,3 @@ |
| 56 | |
| 57 | |
| 58 | -Process terminating with default action of signal 14 (SIGALRM) |
| 59 | - at 0x........: swapcontext (in /...libc...) |
| 60 | - by 0x........: f (swapcontext.c:?) |
| 61 | - |
| 62 | ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) |
| 63 | -- |
| 64 | 2.17.1 |
| 65 | |