Skip to content

Commit 62676d0

Browse files
Edward Liaw via ltpacerv
authored andcommitted
setrlimit01.c: use a more reliable segfault
When compiled for Android, strcpying to the null pointer was being optimized away as unreachable, so the segfault wasn't being thrown. Use raise to throw the segfault instead of ub, since the test just needs the signal. Reviewed-by: Andrea Cervesato <andrea.cervesato@suse.com> Signed-off-by: Edward Liaw <edliaw@google.com>
1 parent de44d81 commit 62676d0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

testcases/kernel/syscalls/setrlimit/setrlimit01.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <sys/wait.h>
3434
#include <errno.h>
3535
#include <fcntl.h>
36+
#include <signal.h>
3637
#include <stdlib.h>
3738
#include <unistd.h>
3839
#include "test.h"
@@ -256,8 +257,7 @@ static void test4(void)
256257
tst_brkm(TBROK, cleanup, "fork() failed");
257258

258259
if (pid == 0) { /* child */
259-
char *testbuf = NULL;
260-
strcpy(testbuf, "abcd");
260+
raise(SIGSEGV);
261261
exit(0);
262262
}
263263
wait(&status);

0 commit comments

Comments
 (0)