All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH v2] waitid10: raise SIGFPE directly
@ 2022-05-12 13:10 Cyril Hrubis
  2022-05-12 19:30 ` Jan Stancek
  2022-05-13  2:02 ` Li Wang
  0 siblings, 2 replies; 6+ messages in thread
From: Cyril Hrubis @ 2022-05-12 13:10 UTC (permalink / raw)
  To: ltp

The SIGFPE for division by zero is actually not send for quite a few
architectures (ARM for instance) and even on x86 and x86_64 we need to
work around compiler to make it generate code that actually triggers the
condition.

So this patch fixes the test in the simplest way possible. the child
just directly raises SIGFPE instead.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 testcases/kernel/syscalls/waitid/waitid10.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/testcases/kernel/syscalls/waitid/waitid10.c b/testcases/kernel/syscalls/waitid/waitid10.c
index e75edd07e..388b31cc9 100644
--- a/testcases/kernel/syscalls/waitid/waitid10.c
+++ b/testcases/kernel/syscalls/waitid/waitid10.c
@@ -24,12 +24,8 @@ static void run(void)
 	pid_t pidchild;
 
 	pidchild = SAFE_FORK();
-	if (!pidchild) {
-		volatile int a, zero = 0;
-
-		a = 1 / zero;
-		exit(a);
-	}
+	if (!pidchild)
+		raise(SIGFPE);
 
 	TST_EXP_PASS(waitid(P_ALL, 0, infop, WEXITED));
 	TST_EXP_EQ_LI(infop->si_pid, pidchild);
-- 
2.35.1


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

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

* Re: [LTP] [PATCH v2] waitid10: raise SIGFPE directly
  2022-05-12 13:10 [LTP] [PATCH v2] waitid10: raise SIGFPE directly Cyril Hrubis
@ 2022-05-12 19:30 ` Jan Stancek
  2022-05-13  2:02 ` Li Wang
  1 sibling, 0 replies; 6+ messages in thread
From: Jan Stancek @ 2022-05-12 19:30 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: LTP List

On Thu, May 12, 2022 at 3:08 PM Cyril Hrubis <chrubis@suse.cz> wrote:
>
> The SIGFPE for division by zero is actually not send for quite a few
> architectures (ARM for instance) and even on x86 and x86_64 we need to
> work around compiler to make it generate code that actually triggers the
> condition.
>
> So this patch fixes the test in the simplest way possible. the child
> just directly raises SIGFPE instead.
>
> Signed-off-by: Cyril Hrubis <chrubis@suse.cz>

Acked-by: Jan Stancek <jstancek@redhat.com>


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

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

* Re: [LTP] [PATCH v2] waitid10: raise SIGFPE directly
  2022-05-12 13:10 [LTP] [PATCH v2] waitid10: raise SIGFPE directly Cyril Hrubis
  2022-05-12 19:30 ` Jan Stancek
@ 2022-05-13  2:02 ` Li Wang
  2022-05-13  9:07   ` Cyril Hrubis
  1 sibling, 1 reply; 6+ messages in thread
From: Li Wang @ 2022-05-13  2:02 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: LTP List


[-- Attachment #1.1: Type: text/plain, Size: 1545 bytes --]

On Thu, May 12, 2022 at 9:08 PM Cyril Hrubis <chrubis@suse.cz> wrote:

> The SIGFPE for division by zero is actually not send for quite a few
> architectures (ARM for instance) and even on x86 and x86_64 we need to
> work around compiler to make it generate code that actually triggers the
> condition.
>
> So this patch fixes the test in the simplest way possible. the child
> just directly raises SIGFPE instead.
>
> Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
> ---
>  testcases/kernel/syscalls/waitid/waitid10.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/waitid/waitid10.c
> b/testcases/kernel/syscalls/waitid/waitid10.c
> index e75edd07e..388b31cc9 100644
> --- a/testcases/kernel/syscalls/waitid/waitid10.c
> +++ b/testcases/kernel/syscalls/waitid/waitid10.c
> @@ -24,12 +24,8 @@ static void run(void)
>         pid_t pidchild;
>
>         pidchild = SAFE_FORK();
> -       if (!pidchild) {
> -               volatile int a, zero = 0;
> -
> -               a = 1 / zero;
> -               exit(a);
> -       }
> +       if (!pidchild)
> +               raise(SIGFPE);
>

Better to have code comments to explain the reason here,
just for better readability.

And vote for merging before the new release as well.

Reviewed-by: Li Wang <liwang@redhat.com>




>
>         TST_EXP_PASS(waitid(P_ALL, 0, infop, WEXITED));
>         TST_EXP_EQ_LI(infop->si_pid, pidchild);
> --
> 2.35.1
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
>
>

-- 
Regards,
Li Wang

[-- Attachment #1.2: Type: text/html, Size: 2945 bytes --]

[-- Attachment #2: Type: text/plain, Size: 60 bytes --]


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

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

* Re: [LTP] [PATCH v2] waitid10: raise SIGFPE directly
  2022-05-13  2:02 ` Li Wang
@ 2022-05-13  9:07   ` Cyril Hrubis
  2022-05-13  9:24     ` Li Wang
  0 siblings, 1 reply; 6+ messages in thread
From: Cyril Hrubis @ 2022-05-13  9:07 UTC (permalink / raw)
  To: Li Wang; +Cc: LTP List

Hi!
> Better to have code comments to explain the reason here,
> just for better readability.

What exactly should we comment there, something as:

Triggering SIGFPE by invalid instruction is not always possible, some
architectures does not trap division-by-zero at all and even when it's
possible we would have to fight the compiler optimizations that have
tendency to remove undefined operations.

> And vote for merging before the new release as well.

That's what I'm aiming for.

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH v2] waitid10: raise SIGFPE directly
  2022-05-13  9:07   ` Cyril Hrubis
@ 2022-05-13  9:24     ` Li Wang
  2022-05-13 12:38       ` Cyril Hrubis
  0 siblings, 1 reply; 6+ messages in thread
From: Li Wang @ 2022-05-13  9:24 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: LTP List


[-- Attachment #1.1: Type: text/plain, Size: 296 bytes --]

> Triggering SIGFPE by invalid instruction is not always possible, some
> architectures does not trap division-by-zero at all and even when it's
> possible we would have to fight the compiler optimizations that have
> tendency to remove undefined operations.
>

Looks good.

-- 
Regards,
Li Wang

[-- Attachment #1.2: Type: text/html, Size: 703 bytes --]

[-- Attachment #2: Type: text/plain, Size: 60 bytes --]


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

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

* Re: [LTP] [PATCH v2] waitid10: raise SIGFPE directly
  2022-05-13  9:24     ` Li Wang
@ 2022-05-13 12:38       ` Cyril Hrubis
  0 siblings, 0 replies; 6+ messages in thread
From: Cyril Hrubis @ 2022-05-13 12:38 UTC (permalink / raw)
  To: Li Wang; +Cc: LTP List

Hi!
Added comment and pushed, thanks for the reviews.

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

end of thread, other threads:[~2022-05-13 12:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-12 13:10 [LTP] [PATCH v2] waitid10: raise SIGFPE directly Cyril Hrubis
2022-05-12 19:30 ` Jan Stancek
2022-05-13  2:02 ` Li Wang
2022-05-13  9:07   ` Cyril Hrubis
2022-05-13  9:24     ` Li Wang
2022-05-13 12:38       ` 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.