Closed Bug 1011823 Opened 10 years ago Closed 10 years ago

Javascript calculates a product of a floating point variable incorrectly

Categories

(Core :: JavaScript Engine, defect)

29 Branch
x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 995542

People

(Reporter: shytor, Unassigned)

Details

Attachments

(1 file)

210.99 KB, application/zip
Details
Attached file screenshots.zip
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:29.0) Gecko/20100101 Firefox/29.0 (Beta/Release)
Build ID: 20140506152807

Steps to reproduce:

I am working on Javascript code to make a simple game. One particular line of code multiplies a variable by itself (sqaures). Th numbers being input are floating point and generally between 0 and 10, rarely integers.


Actual results:

In Firefox 29, the math equation occasionally comes up with an incorrect product. The calculation is run 50 frames per second, it works fine for the first few seconds then fails momentarily and then continues working again. The failure occurs at the EXACT same spot during the run cycle. Refreshing the page does not resolve the issue. However, on Mac OS X Lion, the code runs correctly once after restarting Firefox, but then subsequent refreshes, the code fails. It never works in Mac OS X 10.6.8. The issue does not occur in Safari 5 or 6.


Expected results:

The code should multiply the number to get a correct value. The code in question that I have isolated it to is below. I have included screen shots of the code failing with different numbers.

					var xxx = uvx*uvx;
					var yyy = uvy*uvy;
					ctx.fillText("var x "+uvx,400,100);
					ctx.fillText("x squared"+xxx,400,130);
Component: Untriaged → JavaScript Engine
Product: Firefox → Core
Flags: needinfo?(jdemooij)
Hi shytor, thanks for the bug report!

Unfortunately it's hard to for us to investigate the problem without more info. Would it be possible for you to create a small testcase that demonstrates the problem, and attach it here or host it somewhere? You could also mail it to me if you don't want to attach it here.
Flags: needinfo?(shytor)
Flags: needinfo?(jdemooij)
The reporter sent me a testcase and I was able to reproduce it on OS X.

shytor, our optimizing JIT incorrectly used the value of oldx*oldx instead of uvx*uvx. This is the same issue as bug 995542, I verified the patch there fixes it. The fix for that bug will be in Firefox 30 (you can verify this by downloading a beta build), which will be released next month (June 10).

Thanks again for reporting this and the detailed steps to reproduce, very useful. Let us know if you run into other problems (performance bugs are also welcome).
Status: UNCONFIRMED → RESOLVED
Closed: 10 years ago
Flags: needinfo?(shytor)
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: