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: Non-antialiased, hairline stroke, full width rectangle #100

Open
kosayoda opened this issue Jul 21, 2023 · 1 comment
Open

Panic: Non-antialiased, hairline stroke, full width rectangle #100

kosayoda opened this issue Jul 21, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@kosayoda
Copy link

Hi! I'm getting a panic similar to #20 and #47 with the following code on the latest master:

use tiny_skia::*;

fn main() {
    let mut pixmap = Pixmap::new(100, 100).unwrap();

    let mut path_builder = PathBuilder::new();

    let rect = Rect::from_xywh(0.0, 0.0, 100.0, 100.0).unwrap();
    path_builder.push_rect(rect);

    let path = path_builder.finish().unwrap();

    let mut paint = Paint::default();
    paint.anti_alias = false;

    let mut stroke = Stroke::default();
    stroke.width = 0.0;

    pixmap.stroke_path(&path, &paint, &stroke, Transform::identity(), None);
}

Panic backtrace:

thread 'main' panicked at 'range end index 10001 out of range for slice of length 10000', /home/kosa/.local/share/cargo/git/checkouts/tiny-skia-ff2529ae49675170/d2b7abb/src/pipeline/blitter.rs:325:21
stack backtrace:
   0:     0x5630a5a586c1 - std::backtrace_rs::backtrace::libunwind::trace::h5554868a335b687a
                               at /rustc/36fb58e433c782e27dd41034284e157cf86d587f/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x5630a5a586c1 - std::backtrace_rs::backtrace::trace_unsynchronized::hfd24c2b1bc872c7f
                               at /rustc/36fb58e433c782e27dd41034284e157cf86d587f/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x5630a5a586c1 - std::sys_common::backtrace::_print_fmt::hb40d4835c8544bc2
                               at /rustc/36fb58e433c782e27dd41034284e157cf86d587f/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x5630a5a586c1 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h3d8750c5a9a530aa
                               at /rustc/36fb58e433c782e27dd41034284e157cf86d587f/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x5630a5a7439f - core::fmt::rt::Argument::fmt::h4d7415a32daf52e6
                               at /rustc/36fb58e433c782e27dd41034284e157cf86d587f/library/core/src/fmt/rt.rs:138:9
   5:     0x5630a5a7439f - core::fmt::write::h15119af0af627cb4
                               at /rustc/36fb58e433c782e27dd41034284e157cf86d587f/library/core/src/fmt/mod.rs:1094:21
   6:     0x5630a5a56787 - std::io::Write::write_fmt::hc629dbaef083aeea
                               at /rustc/36fb58e433c782e27dd41034284e157cf86d587f/library/std/src/io/mod.rs:1714:15
   7:     0x5630a5a584d5 - std::sys_common::backtrace::_print::he9d2145ade770793
                               at /rustc/36fb58e433c782e27dd41034284e157cf86d587f/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x5630a5a584d5 - std::sys_common::backtrace::print::h026f51a088c21258
                               at /rustc/36fb58e433c782e27dd41034284e157cf86d587f/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x5630a5a598b3 - std::panicking::default_hook::{{closure}}::h34f469ea2c03adc7
                               at /rustc/36fb58e433c782e27dd41034284e157cf86d587f/library/std/src/panicking.rs:269:22
  10:     0x5630a5a59644 - std::panicking::default_hook::hfd3e1ef4c97a68b4
                               at /rustc/36fb58e433c782e27dd41034284e157cf86d587f/library/std/src/panicking.rs:288:9
  11:     0x5630a5a59e39 - std::panicking::rust_panic_with_hook::hc3be44b7757db76f
                               at /rustc/36fb58e433c782e27dd41034284e157cf86d587f/library/std/src/panicking.rs:705:13
  12:     0x5630a5a59d37 - std::panicking::begin_panic_handler::{{closure}}::ha8f95c8316903adf
                               at /rustc/36fb58e433c782e27dd41034284e157cf86d587f/library/std/src/panicking.rs:597:13
  13:     0x5630a5a58af6 - std::sys_common::backtrace::__rust_end_short_backtrace::h50cf4d5ceed3b7ca
                               at /rustc/36fb58e433c782e27dd41034284e157cf86d587f/library/std/src/sys_common/backtrace.rs:151:18
  14:     0x5630a5a59a82 - rust_begin_unwind
                               at /rustc/36fb58e433c782e27dd41034284e157cf86d587f/library/std/src/panicking.rs:593:5
  15:     0x5630a595eea3 - core::panicking::panic_fmt::hb952c057152cc209
                               at /rustc/36fb58e433c782e27dd41034284e157cf86d587f/library/core/src/panicking.rs:67:14
  16:     0x5630a595f472 - core::slice::index::slice_end_index_len_fail_rt::h11d36dbe3c608f5c
                               at /rustc/36fb58e433c782e27dd41034284e157cf86d587f/library/core/src/slice/index.rs:76:5
  17:     0x5630a595f472 - core::slice::index::slice_end_index_len_fail::hd44b49b92f227a9f
                               at /rustc/36fb58e433c782e27dd41034284e157cf86d587f/library/core/src/slice/index.rs:68:9
  18:     0x5630a598d95f - <core::ops::range::Range<usize> as core::slice::index::SliceIndex<[T]>>::index_mut::h9535f765aa202fac
                               at /rustc/36fb58e433c782e27dd41034284e157cf86d587f/library/core/src/slice/index.rs:419:13
  19:     0x5630a5a11deb - core::slice::index::<impl core::ops::index::IndexMut<I> for [T]>::index_mut::h40da4673d4351703
                               at /rustc/36fb58e433c782e27dd41034284e157cf86d587f/library/core/src/slice/index.rs:29:9
  20:     0x5630a59693ff - <tiny_skia::pipeline::blitter::RasterPipelineBlitter as tiny_skia::blitter::Blitter>::blit_rect::h10aa2c5f5a8a1145
                               at /home/kosa/.local/share/cargo/git/checkouts/tiny-skia-ff2529ae49675170/d2b7abb/src/pipeline/blitter.rs:325:21
  21:     0x5630a59689ca - <tiny_skia::pipeline::blitter::RasterPipelineBlitter as tiny_skia::blitter::Blitter>::blit_h::h900ce4906ed2fae0
                               at /home/kosa/.local/share/cargo/git/checkouts/tiny-skia-ff2529ae49675170/d2b7abb/src/pipeline/blitter.rs:233:9
  22:     0x5630a5a0a810 - tiny_skia::scan::hairline::hair_line_rgn::hb4d2b97ebae2968c
                               at /home/kosa/.local/share/cargo/git/checkouts/tiny-skia-ff2529ae49675170/d2b7abb/src/scan/hairline.rs:141:21
  23:     0x5630a5a0b33f - tiny_skia::scan::hairline::stroke_path_impl::h636291936c1eb32f
                               at /home/kosa/.local/share/cargo/git/checkouts/tiny-skia-ff2529ae49675170/d2b7abb/src/scan/hairline.rs:224:17
  24:     0x5630a5a0a063 - tiny_skia::scan::hairline::stroke_path::h7a059ef1df4ac2e3
                               at /home/kosa/.local/share/cargo/git/checkouts/tiny-skia-ff2529ae49675170/d2b7abb/src/scan/hairline.rs:36:5
  25:     0x5630a598d5a2 - tiny_skia::painter::<impl tiny_skia::pixmap::PixmapMut>::stroke_hairline::h346e8764c597db6b
                               at /home/kosa/.local/share/cargo/git/checkouts/tiny-skia-ff2529ae49675170/d2b7abb/src/painter.rs:462:13
  26:     0x5630a598cdf6 - tiny_skia::painter::<impl tiny_skia::pixmap::PixmapMut>::stroke_path::h9ffd16c046aac18a
                               at /home/kosa/.local/share/cargo/git/checkouts/tiny-skia-ff2529ae49675170/d2b7abb/src/painter.rs:430:21
  27:     0x5630a598ad70 - tiny_skia::painter::<impl tiny_skia::pixmap::Pixmap>::stroke_path::h09e80b5072064ede
                               at /home/kosa/.local/share/cargo/git/checkouts/tiny-skia-ff2529ae49675170/d2b7abb/src/painter.rs:143:9
  28:     0x5630a595fa1f - testing::main::hd5feaac4d9e7398b
                               at /home/kosa/Documents/code/rust/testing/src/main.rs:19:5
  29:     0x5630a595fb2b - core::ops::function::FnOnce::call_once::hdab0e40803267661
                               at /rustc/36fb58e433c782e27dd41034284e157cf86d587f/library/core/src/ops/function.rs:250:5
  30:     0x5630a595fbae - std::sys_common::backtrace::__rust_begin_short_backtrace::h02781e58294858a3
                               at /rustc/36fb58e433c782e27dd41034284e157cf86d587f/library/std/src/sys_common/backtrace.rs:135:18
  31:     0x5630a595f771 - std::rt::lang_start::{{closure}}::h84b2f74c486ba6a1
                               at /rustc/36fb58e433c782e27dd41034284e157cf86d587f/library/std/src/rt.rs:166:18
  32:     0x5630a5a547fb - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h09286b5638482068
                               at /rustc/36fb58e433c782e27dd41034284e157cf86d587f/library/core/src/ops/function.rs:284:13
  33:     0x5630a5a547fb - std::panicking::try::do_call::hc4886f4fd1a5066c
                               at /rustc/36fb58e433c782e27dd41034284e157cf86d587f/library/std/src/panicking.rs:500:40
  34:     0x5630a5a547fb - std::panicking::try::hd44a65a82ab950ab
                               at /rustc/36fb58e433c782e27dd41034284e157cf86d587f/library/std/src/panicking.rs:464:19
  35:     0x5630a5a547fb - std::panic::catch_unwind::h0ee9aa0a1712a08d
                               at /rustc/36fb58e433c782e27dd41034284e157cf86d587f/library/std/src/panic.rs:142:14
  36:     0x5630a5a547fb - std::rt::lang_start_internal::{{closure}}::h1f3410f2df20a4d3
                               at /rustc/36fb58e433c782e27dd41034284e157cf86d587f/library/std/src/rt.rs:148:48
  37:     0x5630a5a547fb - std::panicking::try::do_call::h8900088bbeaeb111
                               at /rustc/36fb58e433c782e27dd41034284e157cf86d587f/library/std/src/panicking.rs:500:40
  38:     0x5630a5a547fb - std::panicking::try::hbd6d94ead609e919
                               at /rustc/36fb58e433c782e27dd41034284e157cf86d587f/library/std/src/panicking.rs:464:19
  39:     0x5630a5a547fb - std::panic::catch_unwind::h26d2b6e104bf4814
                               at /rustc/36fb58e433c782e27dd41034284e157cf86d587f/library/std/src/panic.rs:142:14
  40:     0x5630a5a547fb - std::rt::lang_start_internal::h71c5256da3e502b7
                               at /rustc/36fb58e433c782e27dd41034284e157cf86d587f/library/std/src/rt.rs:148:20
  41:     0x5630a595f74a - std::rt::lang_start::ha1b2d54c9c84c075
                               at /rustc/36fb58e433c782e27dd41034284e157cf86d587f/library/std/src/rt.rs:165:17
  42:     0x5630a595fabe - main
  43:     0x7f5cbf8cd850 - <unknown>
  44:     0x7f5cbf8cd90a - __libc_start_main
  45:     0x5630a595f635 - _start
  46:                0x0 - <unknown>

Conditions:

  1. Non-antialiased
  2. Hairline stroke
  3. The width of the Rect is the width of the Canvas

Changing either one of the three will run without a panic.

@RazrFalcon RazrFalcon added the bug Something isn't working label Jul 22, 2023
@RazrFalcon
Copy link
Collaborator

Can confirm.

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