Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sat, 17 Mar 2012 19:48:01 +0100
From: Szabolcs Nagy <>
Subject: Re: i386 fegetround bug

* Szabolcs Nagy <> [2012-03-17 15:42:44 +0100]:
> fegetround had a bug: eax was not cleared properly
> while fixing it i also changed fesetround see my commit message

i realized my analysis was not entirely correct after rereading
Intel 64 and IA-32 .. Manual, vol.1. 8.6 last paragraph and 8.7.1

it suggests that pending unmasked exceptions can occur
with normal operation (assuming there are unmasked exceptions)
(i just couldn't produce such case from c as an arithmetic op
is usually followed by an fld which traped before i could test
my theory with an fnstenv)

so if we want to be unmasked-exception-friendly then
fnstenv/fldenv pair should be used

(maybe with some extra check for unmasked exceptions first:
fnstcw x
and $0x3f,x
sub $0x3f,x
jnz unmasked_exceptions
and the unmasked_exceptions case uses fnstenv/fldenv, otherwise
plain fldcw is used)

(fnstenv/fldenv can probably hurt those who change rounding
mode frequently, i haven't seen such code but in theory
it makes sense for interval arithmetics)

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.