On 12/21/2016 07:29 AM, David Wohlferd wrote:
> Ahh, the wonders of google.  I believe I have found the problem kai's
> change was originally intended to fix:
> http://mingw-w64-public.narkive.com/jr5jMaJ2/quadmath-h-s-expq-crashes-at-runtime
> 
> 
> And, I believe I have found what the actual problem was.  I don't think
> what kai did was the right fix.  Let me explain why.
> 
> There is a big old structure full of obscure x87 floating point settings
> defined as fenv_t in fenv.h (make sure you don't look at the ARM
> definition by mistake).  The format of this structure is defined by the
> fldenv assembler instruction (so blame Intel).
> 
> Now, someone decided to be tricky and used some of the 'unused' data
> members of this struct to store, not just the x87 FPU settings, but also
> the SSE settings.  It does this by overwriting the __unused0 and
> __unused1 members of the struct.
> 
> So, when you call fegetenv(fenv_t * envp), what you actually get back is
> a mixture of settings for both x87 and SSE.  This isn't (normally) a
> problem, since when you call fesetenv (const fenv_t * envp), it extracts
> the SSE values back out of the struct, puts back the normal 'default'
> values for __unused0 and __unused1, then calls fldenv to set the x87
> values, followed by ldmxcsr for the SSE values.
> 
> However, quadmath doesn't use fegetenv to retrieve the current
> settings.  It uses feholdexcept.  Unfortunately, feholdexcept doesn't
> set __unused0 and __unused1 using the SSE flags the way fegetenv does. 
> As a result, when quadmath eventually calls fesetenv (&oldenv) to put
> things back, the values in __unused0 and __unused1 are not valid SSE
> flag settings.  This is why quadmath was crashing.
> 
> Instead of fixing feholdexcept to use the same format that the rest of
> the fenv_t functions use, kai changed fesetenv as described below.
> 
> I think the correct fix is something like the attached.  This undoes
> kai's change, and fixes feholdexcept instead.  I've taken a brief look,
> and I don't see any other functions that are like this.
> 
> Comments?  Zidane, can you try this?
> 

David, can you also test against the gfortran testsuites? Kai asks to
make sure there are no new failures introduced by this change.

Thanks for looking into it.

Attachment: signature.asc
Description: OpenPGP digital signature

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.http://sdm.link/intel
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to