Catching a "divide by 0"

I have an application which occasionally will cause a “divide by 0” message,
and I was wondering if anyone has any idea on how to catch this event.

The application is running under QNX 6.1. It is currently catching all
signals (including SIGFPE), but QNX does not seem to cause a SIGFPE when I
get the “divide by 0” message. The application seems to continue fine
afterwards, but I would like to find the spot where the divide by 0 is
occurring.

I was thinking that I would try to scatter debug print out in the section
where I suspect it occurring, but that is a pain - as it is fairly
infrequent for it to happen.

Thanks
Jens

Doesn’t it generate a core for the condition? You could always examine the
core to see where the crash happened.

Sreekanth

“Jens H Jorgensen” <jhj@remove-nospam-videk.com> wrote in message
news:b9g7pe$rj9$1@inn.qnx.com

I have an application which occasionally will cause a “divide by 0”
message,
and I was wondering if anyone has any idea on how to catch this event.

The application is running under QNX 6.1. It is currently catching all
signals (including SIGFPE), but QNX does not seem to cause a SIGFPE when I
get the “divide by 0” message. The application seems to continue fine
afterwards, but I would like to find the spot where the divide by 0 is
occurring.

I was thinking that I would try to scatter debug print out in the section
where I suspect it occurring, but that is a pain - as it is fairly
infrequent for it to happen.

Thanks
Jens

Nope - it does not seem to generate any signal and thereby no coredump!


Jens


“Sreekanth” <nospam@nospam.com> wrote in message
news:b9gnt7$g1j$1@inn.qnx.com

Doesn’t it generate a core for the condition? You could always examine the
core to see where the crash happened.

Sreekanth

“Jens H Jorgensen” <> jhj@remove-nospam-videk.com> > wrote in message
news:b9g7pe$rj9$> 1@inn.qnx.com> …
I have an application which occasionally will cause a “divide by 0”
message,
and I was wondering if anyone has any idea on how to catch this event.

The application is running under QNX 6.1. It is currently catching all
signals (including SIGFPE), but QNX does not seem to cause a SIGFPE when
I
get the “divide by 0” message. The application seems to continue fine
afterwards, but I would like to find the spot where the divide by 0 is
occurring.

I was thinking that I would try to scatter debug print out in the
section
where I suspect it occurring, but that is a pain - as it is fairly
infrequent for it to happen.

Thanks
Jens
\

Just to clarify.

I don’t get a SIGFPE with the divide by 0. The only thing I get is a number
of “divide by 0” outputted on stdout.

I made sure that I capture SIGFPE by trying to do a “kill -SIGFPE
process_id”, and the application caught the signal correctly and dumped a
core.

Any ideas?


Jens


“Jens H Jorgensen” <jhj@remove-nospam-videk.com> wrote in message
news:b9goja$gkg$1@inn.qnx.com

Nope - it does not seem to generate any signal and thereby no coredump!


Jens


“Sreekanth” <> nospam@nospam.com> > wrote in message
news:b9gnt7$g1j$> 1@inn.qnx.com> …
Doesn’t it generate a core for the condition? You could always examine
the
core to see where the crash happened.

Sreekanth

“Jens H Jorgensen” <> jhj@remove-nospam-videk.com> > wrote in message
news:b9g7pe$rj9$> 1@inn.qnx.com> …
I have an application which occasionally will cause a “divide by 0”
message,
and I was wondering if anyone has any idea on how to catch this event.

The application is running under QNX 6.1. It is currently catching all
signals (including SIGFPE), but QNX does not seem to cause a SIGFPE
when
I
get the “divide by 0” message. The application seems to continue fine
afterwards, but I would like to find the spot where the divide by 0 is
occurring.

I was thinking that I would try to scatter debug print out in the
section
where I suspect it occurring, but that is a pain - as it is fairly
infrequent for it to happen.

Thanks
Jens


\

Jens H Jorgensen <jhj@remove-nospam-videk.com> wrote:

I don’t get a SIGFPE with the divide by 0. The only thing I get is a number
of “divide by 0” outputted on stdout.

I made sure that I capture SIGFPE by trying to do a “kill -SIGFPE
process_id”, and the application caught the signal correctly and dumped a
core.

Any ideas?

What CPU architecture are you using? On some (SH), the division is performed
by a support routine in libgcc.a, so the support routine may decide
not to cause an exception. On others (PPC), the divide instruction doesn’t
automatically raise an exception for div by zero and you have to instruct
the compiler to insert extra tests. We’ve had issues in the past, but
I thought they were all fixed know (6.1’s old enough that I can’t remember
if they were fixed then though :slight_smile:.


Brian Stecher (bstecher@qnx.com) QNX Software Systems, Ltd.
phone: +1 (613) 591-0931 (voice) 175 Terence Matthews Cr.
+1 (613) 591-3579 (fax) Kanata, Ontario, Canada K2M 1W8

Sorry - I should have told you that I am on x86 platform. The system is
running on a standard PC with a QNX 6.1 installation on it.


Jens

<bstecher@qnx.com> wrote in message news:b9gra1$6b4$1@nntp.qnx.com

Jens H Jorgensen <> jhj@remove-nospam-videk.com> > wrote:
I don’t get a SIGFPE with the divide by 0. The only thing I get is a
number
of “divide by 0” outputted on stdout.

I made sure that I capture SIGFPE by trying to do a “kill -SIGFPE
process_id”, and the application caught the signal correctly and dumped
a
core.

Any ideas?

What CPU architecture are you using? On some (SH), the division is
performed
by a support routine in libgcc.a, so the support routine may decide
not to cause an exception. On others (PPC), the divide instruction doesn’t
automatically raise an exception for div by zero and you have to instruct
the compiler to insert extra tests. We’ve had issues in the past, but
I thought they were all fixed know (6.1’s old enough that I can’t remember
if they were fixed then though > :slight_smile:> .


Brian Stecher (> bstecher@qnx.com> ) QNX Software Systems, Ltd.
phone: +1 (613) 591-0931 (voice) 175 Terence Matthews Cr.
+1 (613) 591-3579 (fax) Kanata, Ontario, Canada K2M
1W8

Jens H Jorgensen <jhj@remove-nospam-videk.com> wrote:

Sorry - I should have told you that I am on x86 platform. The system is
running on a standard PC with a QNX 6.1 installation on it.

What happens when you compile and run the following?

int a,b;

main() { a /= b; }


Are you using C or C++?


Brian Stecher (bstecher@qnx.com) QNX Software Systems, Ltd.
phone: +1 (613) 591-0931 (voice) 175 Terence Matthews Cr.
+1 (613) 591-3579 (fax) Kanata, Ontario, Canada K2M 1W8

Jens H Jorgensen <jhj@remove-nospam-videk.com> wrote:
JHJ > Just to clarify.

JHJ > I don’t get a SIGFPE with the divide by 0. The only thing I get is a number
JHJ > of “divide by 0” outputted on stdout.

JHJ > I made sure that I capture SIGFPE by trying to do a “kill -SIGFPE
JHJ > process_id”, and the application caught the signal correctly and dumped a
JHJ > core.

JHJ > Any ideas?

Can you be certain which application is generating the divide by 0
messages?

I just traced (through debug print out) to the point where it is occurring -
and yes it is actually in library that we purchased where there is a
“printf(“divide by 0\n”);”

Sorry for the false alarm to everybody,
Jens



“Bill Caroselli” <qtps@earthlink.net> wrote in message
news:b9gtf2$k91$5@inn.qnx.com

Jens H Jorgensen <> jhj@remove-nospam-videk.com> > wrote:
JHJ > Just to clarify.

JHJ > I don’t get a SIGFPE with the divide by 0. The only thing I get is a
number
JHJ > of “divide by 0” outputted on stdout.

JHJ > I made sure that I capture SIGFPE by trying to do a “kill -SIGFPE
JHJ > process_id”, and the application caught the signal correctly and
dumped a
JHJ > core.

JHJ > Any ideas?

Can you be certain which application is generating the divide by 0
messages?

I just traced (through debug print out) to the point where it is occurring -
and yes it is actually in library that we purchased where there is a
“printf(“divide by 0\n”);”

Sorry for the false alarm to everybody,
Jens

<bstecher@qnx.com> wrote in message news:b9gt10$7lc$1@nntp.qnx.com

Jens H Jorgensen <> jhj@remove-nospam-videk.com> > wrote:
Sorry - I should have told you that I am on x86 platform. The system is
running on a standard PC with a QNX 6.1 installation on it.

What happens when you compile and run the following?

int a,b;

main() { a /= b; }


Are you using C or C++?


Brian Stecher (> bstecher@qnx.com> ) QNX Software Systems, Ltd.
phone: +1 (613) 591-0931 (voice) 175 Terence Matthews Cr.
+1 (613) 591-3579 (fax) Kanata, Ontario, Canada K2M
1W8