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

Panic : ClipMask::set_path (debug_assert!) #51

Open
Wardenfar opened this issue Jun 23, 2022 · 4 comments
Open

Panic : ClipMask::set_path (debug_assert!) #51

Wardenfar opened this issue Jun 23, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@Wardenfar
Copy link
Contributor

The code below panics.
Latest version : tiny-skia = "0.6.6"

The panic come from the a debug_assert! in src/scan/path.rs

use tiny_skia::*;

fn main() {
    // special value
    let v = -6.40969;

    let clip_path = {
        let mut pb = PathBuilder::new();
        pb.push_circle(v, v, v);
        // special values
        pb.push_circle(823811.0, v, 824467.0);
        pb.finish().unwrap()
    };

    // special values
    let clip_path = clip_path.transform(Transform::from_row(v, 824060.0, 0.0, 0.0, 0.0, 0.0)).unwrap();

    let mut clip_mask = ClipMask::new();
    // panic here
    clip_mask.set_path(500, 500, &clip_path, FillRule::EvenOdd, true);
}

Stacktrace :

thread 'main' panicked at 'assertion failed: edges[curr_idx].last_y >= curr_y as i32', ~/.cargo/registry/src/github.com-1ecc6299db9ec823/tiny-skia-0.6.6/src/scan/path.rs:178:13
stack backtrace:
   0: rust_begin_unwind
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/panicking.rs:143:14
   2: core::panicking::panic
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/panicking.rs:48:5
   3: tiny_skia::scan::path::walk_edges
             at ~/.cargo/registry/src/github.com-1ecc6299db9ec823/tiny-skia-0.6.6/src/scan/path.rs:178:13
   4: tiny_skia::scan::path::fill_path_impl
             at ~/.cargo/registry/src/github.com-1ecc6299db9ec823/tiny-skia-0.6.6/src/scan/path.rs:155:5
   5: tiny_skia::scan::path_aa::fill_path_impl
             at ~/.cargo/registry/src/github.com-1ecc6299db9ec823/tiny-skia-0.6.6/src/scan/path_aa.rs:106:5
   6: tiny_skia::scan::path_aa::fill_path
             at ~/.cargo/registry/src/github.com-1ecc6299db9ec823/tiny-skia-0.6.6/src/scan/path_aa.rs:62:5
   7: tiny_skia::clip::ClipMask::set_path
             at ~/.cargo/registry/src/github.com-1ecc6299db9ec823/tiny-skia-0.6.6/src/clip.rs:94:13
@RazrFalcon
Copy link
Collaborator

Thanks! Will take a look. Probably yet another rounding issue.

@Wardenfar
Copy link
Contributor Author

I found 3 more crashes : maybe we have to somehow include fuzz-like tests.
AFL++ find them very quickly ~250ms. (so maybe be in Github actions/workflows)
What do you think ? @RazrFalcon

@RazrFalcon
Copy link
Collaborator

I'm not sure we should/can do this on CI. But a subcrate, so people can run it themselves is a good idea.
The reason tiny-skia doesn't have fuzzy-testing is because I don't have time implementing it. That's the only reason.

@RazrFalcon RazrFalcon added the bug Something isn't working label Jun 26, 2022
@RazrFalcon
Copy link
Collaborator

RazrFalcon commented Jun 26, 2022

Damn, clipping is implemented a bit incorrectly. I do not handle large paths at all. I would have to rewrite it from scratch. No idea how long it would take.
Clipping is one of the parts that wasn't ported from Skia and it's kinda meh. Skia clipper is like 5 KLOC. See #9

It's a bug, but not very critical one. You have to really try to hit it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants