Skip to contentSkip to conversation

syscalls: modify_ldt02: Fix failure

PATCH New zhaogongyi 3 participants 3 messages May 6, 2021

lore
Share & tools
lore

zhaogongyi

author
#0 lore raw

PATCH 1/1 syscalls: modify_ldt02: Fix failure

Hi Cyril, Petr,

I am sorry, It's my fault. It seems that restore to origin code is more better since it might create a core file.

Best Regards,
Gongyi

Quoted 56 lines

The test was wrong to begin with, if we want to get SEGFAULT from the waitpid() we cannot setup a handler that catches it and exits with 0.

Fixes f5e8e6b11ce8 ("syscalls/modify_ldt: Replace TINFO with TPASS or

TFAIL")

---
 .../kernel/syscalls/modify_ldt/modify_ldt02.c     | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)
testcases/kernel/syscalls/modify_ldt/modify_ldt02.c +1 -15
index e34d3d54d..f911aa5fd 100644
@@ -120,6 +120,7 @@ int main(int ac, char **av)
 
 		tst_old_flush();
 		if ((pid = FORK_OR_VFORK()) == 0) {
+			signal(SIGSEGV, SIG_DFL);
 			val = read_segment(0);
 			exit(1);
 		}
@@ -168,24 +169,10 @@ int read_segment(unsigned int index)
 	return res;
 }
 
-void sigsegv_handler(int sig)
-{
-	tst_resm(TINFO, "received signal: %d", sig);
-	exit(0);
-}
-
 void setup(void)
 {
-	struct sigaction act;
-
-	memset(&act, 0, sizeof(act));
-	sigemptyset(&act.sa_mask);
-
 	tst_sig(FORK, DEF_HANDLER, cleanup);
 
-	act.sa_handler = sigsegv_handler;
-	(void)sigaction(SIGSEGV, &act, NULL);
-
 	TEST_PAUSE;
 }
 
--

2.26.3

--
Mailing list info: https://lists.linux.it/listinfo/ltp

#1 lore raw

PATCH 1/1 syscalls: modify_ldt02: Fix failure

Hi!

Quoted 2 lines

I am sorry, It's my fault. It seems that restore to origin code is more better since it might create a core file.

No this is not solution either, since the original code was broken to begin with.

We do have tst_no_corefile() in the test library, which should be called by tests that cause SEGFAULT on purpose in order to avoid dumping a core, but it looks like it's available only for new library tests. We would have to convert the test to new library first if we wanted to that.

Signature · 2 lines
Cyril Hrubis
[email protected]
#2 lore raw

PATCH 1/1 syscalls: modify_ldt02: Fix failure

Quoted 4 lines

Hi!

Quoted 2 lines

I am sorry, It's my fault. It seems that restore to origin code is more better since it might create a core file.

Quoted 8 lines

No this is not solution either, since the original code was broken to begin with.

We do have tst_no_corefile() in the test library, which should be called by tests that cause SEGFAULT on purpose in order to avoid dumping a core, but it looks like it's available only for new library tests. We would have to convert the test to new library first if we wanted to that.

Thanks for info, I was not aware of tst_no_corefile().

Kind regards,
Petr