-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Description
I tried compiling our codebase and I get SIGFPE in an innocent looking function.
I've added noinline
, to isolate it further. When called deep in the call tree it crashes with SIGFPE (which should be impossible with the given datatypes)
If I call it in an isolated unit-test with the very same parameters (3,0, 200)
it works as expected
[[clang::noinline]]
bool checkIfObjTooBig(uint size_radial, uint size_azimuthal, uint max)
{
return (size_azimuthal > sqrt(2) * max ||
size_radial > sqrt(2) * max);
}
The generated Assembly with the supposed crash location.
mov %esi,%eax
cvtsi2sd %rax,%xmm0
mov %edx,%eax
cvtsi2sd %rax,%xmm1
mulsd 0x2eb12(%rip),%xmm1 # 0x57bfb8
mov %edi,%eax
cvtsi2sd %rax,%xmm2
movapd %xmm1,%xmm3
cmpltpd %xmm2,%xmm3 #<- Supposedly SIGFPE happens here
cmpltpd %xmm0,%xmm1
orpd %xmm3,%xmm1
movd %xmm1,%eax
and $0x1,%al
retq
Command line parameters:
-D_REENTRANT -m64 -march=x86-64 -pipe -fno-strict-aliasing -O2 -g -DNDEBUG -std=c++14
Could it be that some (parts of) registers are polluted and not really cleared beforehand?