Re: [LTP] [PATCH 1/1] recvmmsg01: Workaround segfault on libc variant on 32 bit

Petr Vorel
2024-11-11T09:58:37Z

Hi Wei, all,

...
> > -static void do_test(unsigned int i)
> > +static void verify_recvmmsg(unsigned int i, void *timeout)
> > {
> > struct time64_variants *tv = &variants[tst_variant];
> > struct test_case *tc = &tcase[i];
> > - void *timeout;

> > ts.type = tv->ts_type;
> > tst_ts_set_sec(&ts, tc->tv_sec);
> > tst_ts_set_nsec(&ts, tc->tv_nsec);

> > + TST_EXP_FAIL2(tv->recvmmsg(*tc->fd, *tc->msg_vec, VLEN, 0, timeout),
> > + tc->exp_errno, "recvmmsg() %s", tc->desc);
> > +}
> > +
> > +static void test_bad_addr(unsigned int i)
> > +{
> > + struct time64_variants *tv = &variants[tst_variant];
> > + void *timeout = bad_addr;
> > + pid_t pid;
> > + int status;
> > +
> > + pid = SAFE_FORK();
> > + if (!pid) {
> > + verify_recvmmsg(i, timeout);
> > + _exit(!TST_PASS);
> > + }
> > +
> > + SAFE_WAITPID(pid, &status, 0);
> > +
> > + if (WIFEXITED(status))
> > + return;
> > +
> > + if (tv->ts_type == TST_LIBC_TIMESPEC &&
> > + WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV) {
> > + tst_res(TPASS, "Child killed by signal");
> very nit:
> 1) s/Child killed by signal/Child killed by SIGSEGV signal/
I copy pasted it. Maybe better would be to print "Child killed by expected
signal" because it's IMHO irrelevant which signal it is, right?
Signal name is important only when there is other signal on TFAIL.

> 2) suggest also print out tc->desc
Here in test_bad_addr()? This is only used for a single testcase,
tc->desc is printed for the main testing with TST_EXP_FAIL2(),
therefore I don't think it will help debugging.

> Thanks for create patch fix our current issue.

Thanks for review. I'll try to get to the other testcases this week.

> Reviewed-by: Wei Gao <wegao@suse.com>