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

Don't panic on negative epsilon #537

Merged
merged 2 commits into from
Nov 17, 2020
Merged

Conversation

urschrei
Copy link
Member

Fixes #536

Copy link
Member

@frewsxcv frewsxcv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

your last commit looks good! but there are also some other commits in here!

@urschrei
Copy link
Member Author

🤦‍♂️

@@ -19,6 +19,10 @@ fn rdp<T>(points: &[Point<T>], epsilon: &T) -> Vec<Point<T>>
where
T: Float,
{
// Epsilon must be greater than zero for any meaningful simplification to happen
if *epsilon <= T::zero() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implies some kind of programmer error right? Should we add a debug assertion failure here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming the fuzzer runs against release builds and thus won't trigger the debug assertion? But I might be wrong...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cargo-fuzz builds in release mode with debug assertions

https://github.com/rust-fuzz/cargo-fuzz/blob/799bf534b889859b090b76f2ca1cffdca4ee7455/src/main.rs#L45-L47

https://github.com/rust-fuzz/cargo-fuzz/blob/bde819e87a86e6b1c5c0320e94343a6f97d063bb/src/options.rs#L68-L70

i don't know where the default value for debug-assertions gets set in cargo-fuzz, but i verified locally that debug assertions are enabled

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I don't feel confident about how to resolve this.

I can imagine some cases where it would be interesting if it were possible to reach an assert via the fuzzer, and others, like here, where it wouldn't be interesting.

We could have the convention that debug_assert is the former while assert is the latter, but... that seems pretty limiting.

We could make our own assert macros, like debug_assert_unless_fuzzing!, but that seems a bit much.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To restate, I'm really OK with just merging this as is. 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am feeling very indecisive too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to merging as-is

Copy link
Member

@michaelkirk michaelkirk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Feedback was optional, so take it or leave it.

@@ -19,6 +19,10 @@ fn rdp<T>(points: &[Point<T>], epsilon: &T) -> Vec<Point<T>>
where
T: Float,
{
// Epsilon must be greater than zero for any meaningful simplification to happen
if *epsilon <= T::zero() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to merging as-is

@frewsxcv
Copy link
Member

bors r+

@bors
Copy link
Contributor

bors bot commented Nov 17, 2020

Build succeeded:

@bors bors bot merged commit e78e527 into georust:master Nov 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Passing a negative value for simplify's epsilon will result in a stack overflow
3 participants