All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] syscalls/signal06: fix test for regression with earlier version of gcc and kernel
@ 2016-08-05  6:58 Guangwen Feng
  2016-08-08  8:44 ` Li Wang
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Guangwen Feng @ 2016-08-05  6:58 UTC (permalink / raw)
  To: ltp

1. Currently, following code is incorrect on some releases with
   earlier version of gcc(tested on RHEL5.11GA):

	while (D == d && loop < LOOPS) {

   Because the argument in function test(double d) is used via (%rsp),
   but here we actually need a xmm register to trigger the fpu bug.
   So use global value instead to make sure to take use of xmm.

2. Although this regression test is designed to trigger SIGSEGV
   intentionally, on some releases with old kernel(tested on RHEL5.11GA),
   this will still lead to segmentation fault that terminate the program
   and break the test even though compiling with -O2.  So slightly adjust
   the weight of the codes in child thread to depress SIGSEGV trigger's
   chance while increase LOOPS to ensure reproducible.

Signed-off-by: Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
---
 testcases/kernel/syscalls/signal/signal06.c | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/testcases/kernel/syscalls/signal/signal06.c b/testcases/kernel/syscalls/signal/signal06.c
index 75ef733..81fd138 100644
--- a/testcases/kernel/syscalls/signal/signal06.c
+++ b/testcases/kernel/syscalls/signal/signal06.c
@@ -31,8 +31,8 @@
  * 		Date:   Tue Sep 2 19:57:17 2014 +0200
  *
  *      commit 66463db4fc5605d51c7bb81d009d5bf30a783a2c
- *               Author: Oleg Nesterov <oleg@redhat.com>
- *               Date:   Tue Sep 2 19:57:13 2014 +0200
+ *              Author: Oleg Nesterov <oleg@redhat.com>
+ *              Date:   Tue Sep 2 19:57:13 2014 +0200
  *
  * Reproduce:
  *	Test-case (needs -O2).
@@ -55,20 +55,21 @@ int TST_TOTAL = 5;
 
 #if __x86_64__
 
-#define LOOPS 10000
+#define LOOPS 100000
+#define VALUE 123.456
 
 volatile double D;
 volatile int FLAGE;
 
 char altstack[4096 * 10] __attribute__((aligned(4096)));
 
-void test(double d)
+void test(void)
 {
 	int loop = 0;
 	int pid = getpid();
 
-	D = d;
-	while (D == d && loop < LOOPS) {
+	D = VALUE;
+	while (D == VALUE && loop < LOOPS) {
 		/* sys_tkill(pid, SIGHUP); asm to avoid save/reload
 		 * fp regs around c call */
 		asm ("" : : "a"(__NR_tkill), "D"(pid), "S"(SIGHUP));
@@ -94,12 +95,16 @@ void sigh(int sig LTP_ATTRIBUTE_UNUSED)
 
 void *tfunc(void *arg LTP_ATTRIBUTE_UNUSED)
 {
-	for (; ;) {
-		TEST(mprotect(altstack, sizeof(altstack), PROT_READ));
-		if (TEST_RETURN == -1)
-			tst_brkm(TBROK | TTERRNO, NULL, "mprotect failed");
+	int i;
+
+	for (i = -1; ; i *= -1) {
+		if (i == -1) {
+			TEST(mprotect(altstack, sizeof(altstack), PROT_READ));
+			if (TEST_RETURN == -1)
+				tst_brkm(TBROK | TTERRNO, NULL, "mprotect failed");
+		}
 
-		TEST(mprotect(altstack, sizeof(altstack), PROT_READ|PROT_WRITE));
+		TEST(mprotect(altstack, sizeof(altstack), PROT_READ | PROT_WRITE));
 		if (TEST_RETURN == -1)
 			tst_brkm(TBROK | TTERRNO, NULL, "mprotect failed");
 
@@ -148,7 +153,7 @@ int main(int ac, char **av)
 				tst_brkm(TBROK | TRERRNO, NULL,
 						"pthread_create failed");
 
-			test(123.456);
+			test();
 
 			TEST(pthread_join(pt, NULL));
 			if (TEST_RETURN)
-- 
1.8.4.2




^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2017-02-13  9:12 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-05  6:58 [LTP] [PATCH] syscalls/signal06: fix test for regression with earlier version of gcc and kernel Guangwen Feng
2016-08-08  8:44 ` Li Wang
2016-08-16  3:08   ` Guangwen Feng
2016-09-20  9:59 ` Guangwen Feng
2016-10-05 13:43 ` Cyril Hrubis
2016-10-06 10:31   ` Guangwen Feng
2016-10-06 11:15     ` Cyril Hrubis
2016-10-10  7:05       ` Guangwen Feng
2016-10-10 13:15         ` Cyril Hrubis
2016-10-11  7:17           ` Guangwen Feng
2016-11-16  8:14           ` [LTP] [PATCH v2] " Guangwen Feng
2017-02-09  9:00             ` Guangwen Feng
2017-02-09 16:19             ` Cyril Hrubis
2017-02-13  3:38               ` Guangwen Feng
2017-02-13  9:12                 ` Cyril Hrubis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.