Program received signal SIGFPE, Arithmetic exception.
0x47d2 in vector_sigma_i (stage=1, type=0, from_state=0xefe8, to_state=0xefe0)
at sigma_i.c:42
(gdb) print result
$1 = 1
(gdb) print coefficient
$2 = 0
(gdb) print fact_table[coefficient]
$3 = 1
(gdb)
$4 = 1
(gdb)
and here is the place it complains:
for(j = 0; j < se_size; j++)
{
coefficient = to_state[j] - from_state[j];
for(i=0;i< coefficient;i++)/* emulate integer power */
result *= this_se->u_i[j];
=> result /= fact_table[coefficient];
}
fact_table is been allocated and initialised elsewhere as follows:
/* making a factorial table to be used by the rest of the calculations.
The goal is to reduce the calculation time when buffer is large,
but we first allocate necessary memory dynamically */
if (!(fact_table = (double *)calloc(buffer_size+1,sizeof(double))))
memory_allocation_error();
for(i = 0;i<=buffer_size;i++)
{
fact_table[i] = CalculateFactorial(i);
}
---------------------------------------------
Unfortunately I cannot post the whole program since it is scattered into
15 files. The program is compiled with gcc2.6.3 and run on SunOs as
well as fussy VAX VMS system with absolutely no problem. It is definitely
something related to gcc compiler in linux that I am missing. Could
anybody enlighten me on this kind of problem.
Thanks.
--
--
Mahmoud Saleh Esfahani
Dept. of Comp. Sci. & Comp. Eng. Phone: +61 3 9479 3035
La Trobe University, FAX: +61 3 9479 3060
Try adding a test for NaN being generated at that point:
#include <math.h>
if ( isnan( result ))
fprintf( stderr, "NaN generated\n");
I have a fairly large program that seems to generate NaN's when doing math,
for no apparent reason. It was also compiled with GCC 2.6.3 and runs on
Linux 1.2.13. I suspect a problem with Linux's memory management or swap
file handling. The problem is intermittent and timing dependent.
Any ideas, anyone?
Jonathan Mohr
Augustana University College, Camrose, Alberta, Canada T4V 2R3
e-mail: mo...@augustana.ab.ca