Infinity becomes non-infinity when split and passed through 32/64 typed arrays

RESOLVED INVALID

Status

()

Core
JavaScript Engine
RESOLVED INVALID
6 years ago
6 years ago

People

(Reporter: azakai, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

3.36 KB, application/javascript
Details
(Reporter)

Description

6 years ago
Created attachment 579930 [details]
testcase

The attached testcase gives different results in v8 and spidermonkey. It writes inifinity, and v8 prints that when it is read, but spidermonkey returns a large finite number.

The tricky bit is that this code avoid "alignment problems" by writing the 64-bit double to a temp buffer, which it knows is 64-bit aligned, then uses that to write the 64-bit value in two parts to the main memory array. The same thing is done on read. (This is needed in emscripten because 64-bit doubles are not 64-bit aligned, necessarily, they are only 32-bit aligned. So the temp buffer is 64-bit aligned, and helps get around potential lack of alignment in the main buffer.)
(Reporter)

Comment 1

6 years ago
Ah, nevermind. The issue is that Infinity is not a NaN as a 64-bit double, but it is a NaN as a 32-bit double. That triggers the NaN-modifying code. So going through 32-bit floats breaks the Infinity double into something else.
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.