linebender / linebender/tiny-skia

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

Open
#100 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Rust
Stars
1.6k
Forks
99
Avg merge
2h 52m
Merged PRs (30d)
1

Description

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

```rust
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 - ::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 - 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:: for [T]>::index_mut::h40da4673d4351703
at /rustc/36fb58e433c782e27dd41034284e157cf86d587f/library/core/src/slice/index.rs:29:9
20: 0x5630a59693ff - ::blit_rect::h10aa2c5f5a8a1145
at /home/kosa/.local/share/cargo/git/checkouts/tiny-skia-ff2529ae49675170/d2b7abb/src/pipeline/blitter.rs:325:21
21: 0x5630a59689ca - ::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::::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::::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::::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:: 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 -
44: 0x7f5cbf8cd90a - __libc_start_main
45: 0x5630a595f635 - _start
46: 0x0 -
```

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the panic with the Rust snippet, then inspect src/pipeline/blitter.rs:325 and the hairline path in src/scan/hairline.rs:141 and :224. Add a regression test covering a non-antialiased, zero-width stroke over a full-width rectangle, and verify that it completes without panicking.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
computer-graphics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.