On Tue, May 26, 2020 at 01:32:55PM -0400, Don Cross wrote:
> On Tue, May 26, 2020 at 1:17 PM Ken Moffat <[email protected]> wrote:
>
> > I'm trying to discover why two tests in the testsuite for 'check'
> > always fail for me. I've now got a response that the tests raise
> > SIGFPE but do not receive it. The example is
> >
> > ken@plexi ~/check-debug $cat test.c
> > #include <stdio.h>
> >
> > #include <signal.h>
> >
> >
> > int main() {
> >
> > printf("Before\n");
> >
> > raise(SIGFPE);
> >
> > printf("After\n");
> >
> > return 0;
> >
> > }
> >
> > followed by gcc test.c ; ./a.out
> >
> > That should terminate on the signal, but for me it doesn't:
> >
> > ken@plexi ~/check-debug $./a.out
> > Before
> > After
> >
> >
> > However, if I try a division by zero I do get the exception:
> >
> > ken@plexi ~/check-debug $cat divbyzero.c
> > #include <stdio.h>
> >
> > #include <signal.h>
> >
> >
> > int main() {
> >
> > int a = 1000;
> > int z = 0;
> > int result;
> >
> > printf("Before\n");
> >
> > //raise(SIGFPE);
> > result = a / z;
> >
> > printf("After\n");
> >
> > return result;
> >
> > }
> >
> > gcc -o divbyzero divbyzero.c
> >
> > ken@plexi ~/check-debug $./divbyzero
> > Before
> > Floating point exception
> >
> >
> > Any clues to how I can find what is causing this breakage, please ?
> > It seems to happen on all my machines.
> >
> > ĸen
> >
> >
> Hi Ken,
>
> That is weird. The test works as expected on my Debian machine. Can you
> try running "strace" on your test program? Here's what mine looks like
> (edited for brevity):
>
> strace ./a.out
> #--- edited ---
> write(1, "Before\n", 7Before
> ) = 7
> rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1], [], 8) = 0
> getpid() = 27404
> gettid() = 27404
> tgkill(27404, 27404, SIGFPE) = 0
> rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
> --- SIGFPE {si_signo=SIGFPE, si_code=SI_TKILL, si_pid=27404, si_uid=1000}
> ---
> +++ killed by SIGFPE +++
> Floating point exception
>
> >From "man raise" you can go down the rabbit hole and see that it ends up
> calling tgkill(). It would be interesting to see what's happening on your
> system.
>
> You can also try printing the integer return value of raise(). It is
> supposed to return 0 on success, nonzero on failure. That might be a clue
> too...
> printf("%d\n", raise(SIGFPE));
>
> Don
Hi Don, starting with printing the return value:
Before
0
After
i.e. it apparently succeeded.
I then ran strace on the original version -
write(1, "Before\n", 7) = 7
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1], [], 8) = 0
getpid() = 1567
gettid() = 1567
tgkill(1567, 1567, SIGFPE) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
--- SIGFPE {si_signo=SIGFPE, si_code=SI_TKILL, si_pid=1567, si_uid=1000} ---
write(1, "After\n", 6) = 6
exit_group(0) = ?
+++ exited with 0 +++
Normally I like unexpected successes, but not in this case.
Thanks.
ĸen
--
Do you not know that, what you belittle by the name tree is but the
mere four-dimensional analogue of a whole multidimensional universe
which - no, I can see you do not. -- Druellae (a Dryad)
--
http://lists.linuxfromscratch.org/listinfo/lfs-support
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page
Do not top post on this list.
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?
http://en.wikipedia.org/wiki/Posting_style