"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "stress-bad-altstack.c" between
stress-ng-0.12.09.tar.xz and stress-ng-0.12.10.tar.xz

About: stress-ng will stress test a computer system in various selectable ways. It was designed to exercise various physical subsystems of a computer as well as the various operating system kernel interfaces.

stress-bad-altstack.c  (stress-ng-0.12.09.tar.xz):stress-bad-altstack.c  (stress-ng-0.12.10.tar.xz)
skipping to change at line 59 skipping to change at line 59
static inline void stress_bad_altstack_force_fault(uint8_t *stack_start) static inline void stress_bad_altstack_force_fault(uint8_t *stack_start)
{ {
volatile uint8_t *vol_stack = (volatile uint8_t *)stack_start; volatile uint8_t *vol_stack = (volatile uint8_t *)stack_start;
/* trigger segfault on stack */ /* trigger segfault on stack */
stress_uint8_put(*vol_stack); /* cppcheck-suppress nullPointer */ stress_uint8_put(*vol_stack); /* cppcheck-suppress nullPointer */
*vol_stack = 0; /* cppcheck-suppress nullPointer */ *vol_stack = 0; /* cppcheck-suppress nullPointer */
(void)*vol_stack; /* cppcheck-suppress nullPointer */ (void)*vol_stack; /* cppcheck-suppress nullPointer */
} }
#if defined(SIGXCPU) && \
defined(RLIMIT_CPU)
static void NORETURN MLOCKED_TEXT stress_xcpu_handler(int signum)
{
(void)signum;
_exit(0);
}
#endif
static void NORETURN MLOCKED_TEXT stress_signal_handler(int signum) static void NORETURN MLOCKED_TEXT stress_signal_handler(int signum)
{ {
uint8_t data[STRESS_MINSIGSTKSZ * 2]; uint8_t data[STRESS_MINSIGSTKSZ * 2];
(void)signum; (void)signum;
(void)munmap(stack, STRESS_MINSIGSTKSZ); (void)munmap(stack, STRESS_MINSIGSTKSZ);
(void)memset(data, 0xff, sizeof(data)); (void)memset(data, 0xff, sizeof(data));
stress_uint8_put(data[0]); stress_uint8_put(data[0]);
if (zero_stack != MAP_FAILED) if (zero_stack != MAP_FAILED)
skipping to change at line 149 skipping to change at line 159
if ((errno == EAGAIN) || (errno == EINTR) || (errno == EN OMEM)) if ((errno == EAGAIN) || (errno == EINTR) || (errno == EN OMEM))
goto again; goto again;
pr_err("%s: fork failed: errno=%d: (%s)\n", pr_err("%s: fork failed: errno=%d: (%s)\n",
args->name, errno, strerror(errno)); args->name, errno, strerror(errno));
return EXIT_NO_RESOURCE; return EXIT_NO_RESOURCE;
} else if (pid > 0) { } else if (pid > 0) {
int status, ret; int status, ret;
(void)setpgid(pid, g_pgrp); (void)setpgid(pid, g_pgrp);
/* Parent, wait for child */ /* Parent, wait for child */
ret = shim_waitpid(pid, &status, 0); ret = waitpid(pid, &status, 0);
if (ret < 0) { if (ret < 0) {
if (errno != EINTR) if (errno != EINTR)
pr_dbg("%s: waitpid(): errno=%d (%s)\n", pr_dbg("%s: waitpid(): errno=%d (%s)\n",
args->name, errno, strerror(errno )); args->name, errno, strerror(errno ));
(void)kill(pid, SIGTERM); (void)kill(pid, SIGTERM);
(void)kill(pid, SIGKILL); (void)kill(pid, SIGKILL);
(void)shim_waitpid(pid, &status, 0); (void)waitpid(pid, &status, 0);
} else if (WIFSIGNALED(status)) { } else if (WIFSIGNALED(status)) {
/* If we got killed by OOM killer, re-start */ /* If we got killed by OOM killer, re-start */
if (WTERMSIG(status) == SIGKILL) { if (WTERMSIG(status) == SIGKILL) {
if (g_opt_flags & OPT_FLAGS_OOMABLE) { if (g_opt_flags & OPT_FLAGS_OOMABLE) {
stress_log_system_mem_info(); stress_log_system_mem_info();
pr_dbg("%s: assuming killed by OO M " pr_dbg("%s: assuming killed by OO M "
"killer, bailing out " "killer, bailing out "
"(instance %d)\n", "(instance %d)\n",
args->name, args->instanc e); args->name, args->instanc e);
_exit(0); _exit(0);
skipping to change at line 184 skipping to change at line 194
} }
} }
/* expected: child killed itself with SIGSEGV */ /* expected: child killed itself with SIGSEGV */
if (WTERMSIG(status) == SIGSEGV) if (WTERMSIG(status) == SIGSEGV)
inc_counter(args); inc_counter(args);
} }
} else if (pid == 0) { } else if (pid == 0) {
uint32_t rnd; uint32_t rnd;
int ret; int ret;
stack_t ss, old_ss; stack_t ss, old_ss;
#if defined(SIGXCPU) && \
defined(RLIMIT_CPU)
struct rlimit rlim;
#endif
if (sigsetjmp(jmpbuf, 1) != 0) { if (sigsetjmp(jmpbuf, 1) != 0) {
/* /*
* We land here if we get a segfault * We land here if we get a segfault
* but not a segfault in the sighandler * but not a segfault in the sighandler
*/ */
if (!keep_stressing(args)) if (!keep_stressing(args))
_exit(0); _exit(0);
} }
skipping to change at line 222 skipping to change at line 236
/* Exercise less than minimum allowed stack size, ENOMEM */ /* Exercise less than minimum allowed stack size, ENOMEM */
ss.ss_sp = stress_align_address(stack, STACK_ALIGNMENT); ss.ss_sp = stress_align_address(stack, STACK_ALIGNMENT);
ss.ss_size = STRESS_MINSIGSTKSZ - 1; ss.ss_size = STRESS_MINSIGSTKSZ - 1;
ss.ss_flags = 0; ss.ss_flags = 0;
(void)sigaltstack(&ss, NULL); (void)sigaltstack(&ss, NULL);
if (stress_sighandler(args->name, SIGSEGV, stress_signal_ handler, NULL) < 0) if (stress_sighandler(args->name, SIGSEGV, stress_signal_ handler, NULL) < 0)
return EXIT_FAILURE; return EXIT_FAILURE;
if (stress_sighandler(args->name, SIGBUS, stress_signal_h andler, NULL) < 0) if (stress_sighandler(args->name, SIGBUS, stress_signal_h andler, NULL) < 0)
return EXIT_FAILURE; return EXIT_FAILURE;
#if defined(SIGXCPU) && \
defined(RLIMIT_CPU)
if (stress_sighandler(args->name, SIGXCPU, stress_xcpu_ha
ndler, NULL) < 0)
return EXIT_FAILURE;
rlim.rlim_cur = 1;
rlim.rlim_max = 1;
(void)setrlimit(RLIMIT_CPU, &rlim);
#endif
/* Set alternative stack for testing */ /* Set alternative stack for testing */
if (stress_sigaltstack(stack, STRESS_MINSIGSTKSZ) < 0) if (stress_sigaltstack(stack, STRESS_MINSIGSTKSZ) < 0)
return EXIT_FAILURE; return EXIT_FAILURE;
/* Child */ /* Child */
stress_mwc_reseed(); stress_mwc_reseed();
rnd = stress_mwc32() % 10; rnd = stress_mwc32() % 10;
stress_set_oom_adjustment(args->name, true); stress_set_oom_adjustment(args->name, true);
 End of changes. 5 change blocks. 
2 lines changed or deleted 26 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)