Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure the result of calculation is finite number. #1296

Merged

Conversation

@mephisto41
Copy link
Contributor

mephisto41 commented May 26, 2017

In this test, we create a very large transform which exceed max of float. This results many NaN or infinite numbers. If we don't handle it, the partial_cmp with Nan or infinite numbers would cause crash.


This change is Reviewable

Copy link
Member

kvark left a comment

Thank you for the PR!
I got one small request, otherwise happy with it.

@@ -150,6 +150,15 @@ pub fn subtract_rect<U>(rect: &TypedRect<f32, U>,
}
}
}

pub fn ensure_float_is_normal(x: f32) -> f32 {

This comment has been minimized.

@kvark

kvark May 26, 2017

Member

This is rather minor, since the function is only used once, but if we want to make it generally useful, I think we should have an API like get_normal(x: f32) -> Option<f32>, so that the function clients do unwrap_or(0.0) (or other value, depending on the context).

This comment has been minimized.

@mephisto41

mephisto41 May 26, 2017

Author Contributor

Thanks for the suggestion. I'll update the PR soon.

@mephisto41 mephisto41 force-pushed the mephisto41:ensure-numbers-arent-nan-or-infinite branch from 3dde1a7 to 517c172 May 26, 2017
@kvark
Copy link
Member

kvark commented May 26, 2017

@bors-servo
Copy link
Contributor

bors-servo commented May 26, 2017

📌 Commit 517c172 has been approved by kvark

@bors-servo
Copy link
Contributor

bors-servo commented May 26, 2017

Testing commit 517c172 with merge 150da47...

bors-servo added a commit that referenced this pull request May 26, 2017
…, r=kvark

Ensure the result of calculation is finite number.

In this [test](https://searchfox.org/mozilla-central/source/dom/animation/test/crashtests/1272475-1.html), we create a very large transform which exceed max of float. This results many NaN or infinite numbers. If we don't handle it, the partial_cmp with Nan or infinite numbers would cause crash.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/1296)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented May 26, 2017

☀️ Test successful - status-travis
Approved by: kvark
Pushing 150da47 to master...

@bors-servo bors-servo merged commit 517c172 into servo:master May 26, 2017
3 checks passed
3 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@staktrace staktrace mentioned this pull request May 29, 2017
3 of 3 tasks complete
@staktrace
Copy link
Contributor

staktrace commented May 29, 2017

@mephisto41 This PR appears to cause a panic in gecko crashtests, when running dom/animation/test/crashtests/1272475-1.html. Backtrace can be found at https://treeherder.mozilla.org/logviewer.html#?job_id=102467951&repo=try&lineNumber=2240

@kvark
Copy link
Member

kvark commented May 29, 2017

@staktrace interesting, so the only new call this PR makes is f32::is_normal, which is from Rust std library: https://doc.rust-lang.org/stable/std/primitive.f32.html#method.is_normal

It doesn't appear to be unsafe to me, so I don't understand why build bots crash on it. Besides, I can't repro it either. Can you? Nvm, I see it, looking at it now :)

@staktrace
Copy link
Contributor

staktrace commented May 29, 2017

Based on the line number in the stack, it seems to be coming from this line so most likely an underflow?

@kvark
Copy link
Member

kvark commented May 29, 2017

Yes, see #1302
AFAIK, the test case passes an absurd transformation, which gets some of the vertices detected as abnormal (and zeroed out), which ends up subtracting -0x80000000 from 0, which is not representable as an i32.

bors-servo added a commit that referenced this pull request May 29, 2017
Overflowing protection for TransformedRect

Fixes #1296 (comment)

cc @staktrace @mephisto41
r? @glennw or anyone

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/1302)
<!-- Reviewable:end -->
bors-servo added a commit that referenced this pull request May 29, 2017
Overflowing protection for TransformedRect

Fixes #1296 (comment)

cc @staktrace @mephisto41
r? @glennw or anyone

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/1302)
<!-- Reviewable:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.