Dealing with floating point exceptions

I’ve been getting Floating point exception at different iterations in my code. I am not using shuffling, but even then this error arises randomly. There is no traceback of this error as well, so I’m unable to find the occurence of this error. I’ve tried pdb/(try-except) but they won’t work in in this case. I haven’t tried with fpectl, but not sure if it would be useful for this. Is there a better way to find the occurence (in the form of a traceback) of Floating point exception (core dumped) ?

Could you try to get a stack trace using gdb:

$ gdb --args python my_script.py
...
Reading symbols from python...done.
(gdb) run
...
(gdb) backtrace
...

Thanks for replying. I got this:

During startup program terminated with signal SIGFPE, Arithmetic exception.
(gdb) backtrace
No stack.

I’ve done everything to remove bad samples, but still it persists.