Re: [Full-disclosure] Firefox 2.0.0.7 has a very serious calculation bug



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri, Sep 28, 2007 at 09:09:02PM +0200, Michal Zalewski wrote:
On Sat, 29 Sep 2007, Jimby Sharp wrote:

I don't get the same from C-style double arithmetics. Could you provide
a sample code that you believe should show the same behavior?

If you don't, it's presumably because the subtraction is optimized out by
the compiler, or because you printf() with an insufficient precision in
format spec. The following should do the trick:

volatile double a = 5.2;
volatile double b = 0.1;
main() { printf("%.16lf\n",a-b); }

Isn't this the same issue pointed out by Brian Kim (double to float
conversion) ?

Look the results I get for the following code:

volatile double a = 5.2;
volatile double b = 0.1;
main() {
printf("%.16lf\n",a);
printf("%.16lf\n",b);
printf("%.16lf\n",(volatile double) 5.1);
printf("%.16lf\n",(volatile double)((float) 5.1));
printf("%.16lf\n",a-b);
}


Results:
5.2000000000000002
0.1000000000000000
5.0999999999999996
5.0999999046325684 <------------
5.1000000000000005


- --
Rodrigo Barbosa
"Quid quid Latine dictum sit, altum viditur"
"Be excellent to each other ..." - Bill & Ted (Wyld Stallyns)

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)

iD8DBQFG/VmCpdyWzQ5b5ckRArw8AJ9snBYsgIK7pvwHbILw43gTtuz6rwCgqxGO
snsqqiu9zDaqhITIe/Ycf7o=
=MJfE
-----END PGP SIGNATURE-----

_______________________________________________
Full-Disclosure - We believe in it.
Charter: http://lists.grok.org.uk/full-disclosure-charter.html
Hosted and sponsored by Secunia - http://secunia.com/



Relevant Pages

  • Re: [Full-disclosure] Firefox 2.0.0.7 has a very serious calculation bug
    ... it's presumably because the subtraction is optimized out by ... the compiler, or because you printfwith an insufficient precision in ... volatile double a = 5.2; ... "Quid quid Latine dictum sit, ...
    (Full-Disclosure)
  • Re: [Full-disclosure] Firefox 2.0.0.7 has a very serious calculation bug
    ... On Sat, 29 Sep 2007, Jimby Sharp wrote: ... a sample code that you believe should show the same behavior? ... it's presumably because the subtraction is optimized out by ... volatile double a = 5.2; ...
    (Full-Disclosure)
  • Re: [Full-disclosure] Firefox 2.0.0.7 has a very serious calculation bug
    ... a sample code that you believe should show the same behavior? ... it's presumably because the subtraction is optimized out by ... the compiler, or because you printfwith an insufficient precision in ... volatile double a = 5.2; ...
    (Full-Disclosure)
  • Re: Is the following code MT-Safe?
    ... the assert (which is a fundamental design error: ... and almost always leads to either major synchronization failures ... >Does _bRunning need to be tagged as volatile? ... compiler to cache values, but only during the execution of a function; ...
    (microsoft.public.vc.mfc)
  • Re: Volatile + multithreading
    ... The volatile keyword has little use in multithreaded programming. ... > field or global seems to have no impact because it seems the compiler will ... operations as "special" and suppress optimizations around them. ... > majority of the multithreading issues that could have resulted from ...
    (microsoft.public.vc.language)