473,396 Members | 1,743 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

floating point exception (SIGFPE weirdness)

I'm running into trouble when calling a 3rd party library (the Intel IPP
library to do some fast math on a P4 processor). This is on debian
linux 2.6.7 using python 2.3.4.

I've been using Pyrex to wrap my calls to this C library into an
extension module, and a certain function call within my extension module
(to the C function ippiAddWeighted_8u32f_C1IR) will terminate my Python
program when called for the 2nd time, with the line "Floating point
exception" mysteriously appearing on the console. (Mysterious in part
because I can't redirect these words with piping stdout or stderr.) I
should note that this function calls not only the normal Pentium
floating-point machinery, but should also call the SSE and SSE2
instruction sets.

A few clues:

1) A trivial C program which makes the same function call repeatedly
with the same data is not terminated.

2) Running the python executable under gdb causes the program to
continue running without terminating.

3) The behavior (termination) is not changed after rebuilding Python
from source, compiling with --with-fpectl and building the fpectl
module, calling fpectl.turnoff_sigfpe().

I don't really understand what is happening, but I'd like my code to run
without terminating due to this floating point exception. My best guess
is that SIGFPE is being generated by the C function call, and Python
does not catch it so the OS terminates Python. If this is so, however,
I'm not sure why Python should be terminated and why my simple C program
is not. Furthermore, I don't understand why gdb doesn't see SIGFPE if
this is the case.

I would be very grateful if someone could tell me how to keep my program
running!

Cheers!
Andrew
Jul 18 '05 #1
1 3308
I figured out that the culprit is in the numarray.ieeespecial module,
which my Python code imports.

The lines (taken from ieeespecial.py)

import numarray.numarrayall as _na
plus_inf = inf = _na.array(1.0)/_na.array(0.0)

are sufficient to cause the behavior in my original post. I shall
follow this up on the numpy discussion list.

Andrew Straw wrote:
I'm running into trouble when calling a 3rd party library (the Intel IPP
library to do some fast math on a P4 processor). This is on debian
linux 2.6.7 using python 2.3.4.

I've been using Pyrex to wrap my calls to this C library into an
extension module, and a certain function call within my extension module
(to the C function ippiAddWeighted_8u32f_C1IR) will terminate my Python
program when called for the 2nd time, with the line "Floating point
exception" mysteriously appearing on the console. (Mysterious in part
because I can't redirect these words with piping stdout or stderr.) I
should note that this function calls not only the normal Pentium
floating-point machinery, but should also call the SSE and SSE2
instruction sets.

A few clues:

1) A trivial C program which makes the same function call repeatedly
with the same data is not terminated.

2) Running the python executable under gdb causes the program to
continue running without terminating.

3) The behavior (termination) is not changed after rebuilding Python
from source, compiling with --with-fpectl and building the fpectl
module, calling fpectl.turnoff_sigfpe().

I don't really understand what is happening, but I'd like my code to run
without terminating due to this floating point exception. My best guess
is that SIGFPE is being generated by the C function call, and Python
does not catch it so the OS terminates Python. If this is so, however,
I'm not sure why Python should be terminated and why my simple C program
is not. Furthermore, I don't understand why gdb doesn't see SIGFPE if
this is the case.

I would be very grateful if someone could tell me how to keep my program
running!

Cheers!
Andrew

Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Lionel B | last post by:
Greetings, Using gcc (GCC) 3.3.3 (cygwin special) on Win2K Does anyone know if there is a convenient mechanism to cause a C++ exception to be thrown whenever a IEEE 754 floating-point...
10
by: Vinny | last post by:
I have a few floating point questions/issues I wish to ask. An answer or discussion would be nice too :) Any links discussion the subject would be nice too.. 1. How do I generate an underflow...
16
by: BigMan | last post by:
How can I check if assignment of a float to a double (or vice versa) will result in loss of precision?
3
by: Mark L Pappin | last post by:
<puts on Compiler Vendor hat> I've recently discovered that our compilers don't make any attempt to handle floating point overflow in add/subtract/ multiply/divide, with the result that...
15
by: michael.mcgarry | last post by:
Hi, I have a question about floating point precision in C. What is the minimum distinguishable difference between 2 floating point numbers? Does this differ for various computers? Is this...
4
by: jacob navia | last post by:
Hi people I continue to work in the tutorial for lcc-win32, and started to try to explain the floating point flags. Here is the relevant part of the tutorial. Since it is a difficult part, I...
4
by: John Pye | last post by:
Hi all I have some C code that is giving me some 'nan' values in some calculations. The C code is wrapped using SWIG to give me a Python module that I am then exercising through a unittest...
24
by: usenet | last post by:
I am unable to catch floating exceptions (e.g. divide by 0 or 0/0) using the standard exceptions defined in stdexcept. What is the recommended way to catch such exceptions? Thanks, Song
39
by: rembremading | last post by:
Hi all! The following piece of code has (for me) completely unexpected behaviour. (I compile it with gcc-Version 4.0.3) Something goes wrong with the integer to float conversion. Maybe somebody...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.