[Numpy-discussion] Floating point exception with numpy and embedded python interpreter

Andrew Straw strawman at astraw.com
Mon Apr 24 14:33:01 EDT 2006


This doesn't seem like an issue with numpy. Your test proved that. I'm
curious what the outcome is, but I'm afraid there's not much we can do.

At this point I think you should write the ns2 people and see what they
say. Their program seems to be responsible for twiddling the FPU/SSE
flags, so I think the issue is better solved, or at least discussed, by
them.

Cheers!
Andrew

Arkaitz Bitorika wrote:

> Andrew,
>
> I've verified that the function causes the exception when embedded in 
> the program but not when used from a simple C program with just a main
> () function. The successful version iterates 31 times over the for 
> loop while the crashing one fails the 30th time that it does "pinf *= 
> mul".
>
> Now we know exactly where the crash is, but no idea how to fix it ;). 
> It doesn't look it should be related to SSE2 flags, it's just doing a 
> big multiplication, but I don't know enough about low level C and 
> floating point operations to understand why it may be throwing the 
> exception there. Any idea how I could avoid that function crashing?
>
> Thanks,
> Arkaitz
>
> On 22 Apr 2006, at 20:12, Andrew Straw wrote:
>
>> OK, going back to your original gdb traceback, it looks like the  SIGFPE
>> originated in the following funtion in umathmodule.c:
>>
>> static double
>> pinf_init(void)
>> {
>>     double mul = 1e10;
>>     double tmp = 0.0;
>>     double pinf;
>>
>>     pinf = mul;
>>     for (;;) {
>>         pinf *= mul;
>>         if (pinf == tmp) break;
>>         tmp = pinf;
>>     }
>>     return pinf;
>> }
>>
>> If you try just that function (instead of the whole Python interpreter
>> and numpy module) and still get the exception, you'll be that much
>> closer to narrowing down the issue.
>




More information about the NumPy-Discussion mailing list