Differential output with Math functions and Ion
Categories
(Core :: JavaScript Engine: JIT, defect, P1)
Tracking
()
People
(Reporter: decoder, Assigned: iain)
Details
(Keywords: regression, testcase, Whiteboard: [bugmon:update,bisect])
Attachments
(2 files)
The following testcase produces differential results on mozilla-central revision 20210216-00b18dc4bfac (debug build, run with --no-threads --differential-testing --fuzzing-safe test.js):
function testMathyFunction (f, inputs) {
for (var j = 0; j < inputs.length; ++j)
for (var k = 0; k < inputs.length; ++k)
print(f(inputs[j], inputs[k]))
}
mathy0 = (function(x, y) {
return Math.asinh(y | 0) | 0 ? Math.fround(~ x) : Math.hypot(Math.sqrt(2**53), Math.sqrt([, ...[]]));
});
testMathyFunction(mathy0, [Math.PI, 2**53]);
With --no-threads --differential-testing --fuzzing-safe:
-4
94906265.62425156
-1
94906265.62425156
With --no-threads --differential-testing --fuzzing-safe --ion-eager:
-4
94906265.62425156
-1
94906264
Marking s-s until investigated because this is a JIT optimization bug.
Reporter | ||
Comment 1•4 years ago
|
||
Assignee | ||
Comment 3•4 years ago
|
||
Looked at it earlier today. It's not s-s. We're losing precision by specializing a sqrt
to Float32 in a corner case involving FirstExecution bailouts. I'm still working on pinning down the details.
Comment 4•4 years ago
|
||
Losing precision doesn't seem like a security problem.
Assignee | ||
Comment 5•4 years ago
|
||
When the only consumer of Math.sqrt(2**53)
was in code that had never been executed, the float32 optimization tried to convert it to float32 (in MSqrt::trySpecializeFloat32) because we didn't see any consumers that couldn't accept float32. When we bailed out, we recovered the result as a float instead of a double, and lost precision (94906264 vs 94906265.62425156). Checking for implicit uses solves the problem.
bug1693062-01.js
tests CheckUsesAreFloat32Consumers
. bug1693062-02.js
tests TypeAnalyzer::markPhiConsumers
. (The difference is whether the instruction we want to specialize is implicitly used itself, or whether it is used by an implicitly used phi.) These are the only places that canConsumeFloat32
is called outside of assertions.
Updated•4 years ago
|
Comment 6•4 years ago
|
||
Setting S3, because it is possible to have work-around, however, I seems to me that this would be something to backport if applicable.
Assignee | ||
Comment 7•4 years ago
|
||
It's pretty hard to trigger this by mistake. If you do, you end up with slightly less precise results 10 times, then you bail out and recompile with a concrete consumer of the incorrectly specialized instruction. There are no security concerns.
I think it's fine to let this ride the trains.
Comment 9•4 years ago
|
||
bugherder |
Comment 10•4 years ago
|
||
Bugmon Analysis:
Bug appears to be fixed on mozilla-central 20210218214637-b82bd51a119e but BugMon was unable to reproduce using mozilla-central 20210216031051-00b18dc4bfac.
Removing bugmon keyword as no further action possible.
Please review the bug and re-add the keyword for further analysis.
Updated•4 years ago
|
Comment 11•3 years ago
|
||
:iain, since this bug contains a bisection range, could you fill (if possible) the regressed_by field?
For more information, please visit auto_nag documentation.
Assignee | ||
Updated•3 years ago
|
Description
•