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

[BUG] thread 'main' panicked at 'attempt to subtract with overflow' in polygon.rs #133

Closed
BlackYoup opened this issue Apr 25, 2020 · 5 comments
Labels
bug Something isn't working

Comments

@BlackYoup
Copy link

BlackYoup commented Apr 25, 2020

Hello,

Describe the bug
When rendering a graph with a single serie which has a stroke_width of 2 (or more), I'm getting this overflow.

To Reproduce
Here is the code: https://github.com/makers-for-life/makair/blob/1b4eab920f628dd060363c6061a31a6e6a4f6804/src/software/control/src/display/renderer.rs#L120

I changed the stroke_width to 2 on line 143.

The graph is fully rendered each time (we don't use a shared ChartContext for now)

I'll let you know once you can run it to draw a graph with some sampled data to reproduce the issue with this project.

It works fines with a line_stroke of 1. Did I miss something somewhere?

Version Information
0.2.12

The full backtrace:

thread 'main' panicked at 'attempt to subtract with overflow', /home/arnaud/.cargo/registry/src/github.com-1ecc6299db9ec823/plotters-0.2.12/src/drawing/rasterizer/polygon.rs:101:32
stack backtrace:
   0:     0x5631c3f43d94 - backtrace::backtrace::libunwind::trace::h5ae3454ebe40b621
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/libunwind.rs:86
   1:     0x5631c3f43d94 - backtrace::backtrace::trace_unsynchronized::hbf6f267a483fb2c0
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/mod.rs:66
   2:     0x5631c3f43d94 - std::sys_common::backtrace::_print_fmt::h37755015d94b9085
                               at src/libstd/sys_common/backtrace.rs:78
   3:     0x5631c3f43d94 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h0561c8cd3569b40d
                               at src/libstd/sys_common/backtrace.rs:59
   4:     0x5631c3f65fbc - core::fmt::write::h86a597a35d48a212
                               at src/libcore/fmt/mod.rs:1063
   5:     0x5631c3f41183 - std::io::Write::write_fmt::h73d9dc0f29eefe48
                               at src/libstd/io/mod.rs:1426
   6:     0x5631c3f465d5 - std::sys_common::backtrace::_print::h6c60c5ee09af0233
                               at src/libstd/sys_common/backtrace.rs:62
   7:     0x5631c3f465d5 - std::sys_common::backtrace::print::hf9d1db01634f9b2a
                               at src/libstd/sys_common/backtrace.rs:49
   8:     0x5631c3f465d5 - std::panicking::default_hook::{{closure}}::h1db9298dd213ae95
                               at src/libstd/panicking.rs:204
   9:     0x5631c3f46322 - std::panicking::default_hook::h3272faf6cc91fd2e
                               at src/libstd/panicking.rs:224
  10:     0x5631c3f46c32 - std::panicking::rust_panic_with_hook::hb976084785e50594
                               at src/libstd/panicking.rs:470
  11:     0x5631c3f4681b - rust_begin_unwind
                               at src/libstd/panicking.rs:378
  12:     0x5631c3f64981 - core::panicking::panic_fmt::h45f7d6868edb5678
                               at src/libcore/panicking.rs:85
  13:     0x5631c3f648cd - core::panicking::panic::h0fd4184f909d9498
                               at src/libcore/panicking.rs:52
  14:     0x5631c36eb275 - plotters::drawing::rasterizer::polygon::fill_polygon::h8771bd6a8e1603a0
                               at /home/arnaud/.cargo/registry/src/github.com-1ecc6299db9ec823/plotters-0.2.12/src/drawing/rasterizer/polygon.rs:101
  15:     0x5631c366ae59 - plotters::drawing::backend::DrawingBackend::fill_polygon::hae7c63822c3eb224
                               at /home/arnaud/.cargo/registry/src/github.com-1ecc6299db9ec823/plotters-0.2.12/src/drawing/backend.rs:176
  16:     0x5631c366b50f - plotters::drawing::backend::DrawingBackend::draw_path::h1b208beefac535ce
                               at /home/arnaud/.cargo/registry/src/github.com-1ecc6299db9ec823/plotters-0.2.12/src/drawing/backend.rs:149
  17:     0x5631c36cbf07 - <plotters::element::basic_shapes::PathElement<Coord> as plotters::element::Drawable<DB>>::draw::h68df442b040bfb4f
                               at /home/arnaud/.cargo/registry/src/github.com-1ecc6299db9ec823/plotters-0.2.12/src/element/basic_shapes.rs:98
  18:     0x5631c36cc1e8 - <T as plotters::element::dynelem::DynDrawable<DB>>::draw_dyn::hf7e74f4670164f41
                               at /home/arnaud/.cargo/registry/src/github.com-1ecc6299db9ec823/plotters-0.2.12/src/element/dynelem.rs:22
  19:     0x5631c3704ed3 - <plotters::element::dynelem::DynElement<DB,Coord> as plotters::element::Drawable<DB>>::draw::h434a28978b4ec955
                               at /home/arnaud/.cargo/registry/src/github.com-1ecc6299db9ec823/plotters-0.2.12/src/element/dynelem.rs:53
  20:     0x5631c36b480d - plotters::drawing::area::DrawingArea<DB,CT>::draw::{{closure}}::h4327eb5c91617b55
                               at /home/arnaud/.cargo/registry/src/github.com-1ecc6299db9ec823/plotters-0.2.12/src/drawing/area.rs:314
  21:     0x5631c36b31bf - plotters::drawing::area::DrawingArea<DB,CT>::backend_ops::h915d98c735c495ff
                               at /home/arnaud/.cargo/registry/src/github.com-1ecc6299db9ec823/plotters-0.2.12/src/drawing/area.rs:271
  22:     0x5631c36b46ae - plotters::drawing::area::DrawingArea<DB,CT>::draw::hb8cdcaff6b3ce96f
                               at /home/arnaud/.cargo/registry/src/github.com-1ecc6299db9ec823/plotters-0.2.12/src/drawing/area.rs:314
  23:     0x5631c36dfa37 - plotters::chart::context::ChartContext<DB,plotters::coord::ranged::RangedCoord<X,Y>>::draw_series_impl::heac5c2cf8e566023
                               at /home/arnaud/.cargo/registry/src/github.com-1ecc6299db9ec823/plotters-0.2.12/src/chart/context.rs:340
  24:     0x5631c36ddf95 - plotters::chart::context::ChartContext<DB,plotters::coord::ranged::RangedCoord<X,Y>>::draw_series::h00b2bab30cec1fe1
                               at /home/arnaud/.cargo/registry/src/github.com-1ecc6299db9ec823/plotters-0.2.12/src/chart/context.rs:362
  25:     0x5631c36a2fec - makair_control::display::renderer::DisplayRenderer::data::h6e68c0cc7818113e
                               at src/display/renderer.rs:138
  26:     0x5631c36a2611 - makair_control::display::renderer::DisplayRenderer::render::h417da5ab37785418
                               at src/display/renderer.rs:49
  27:     0x5631c36a06ef - makair_control::display::drawer::DisplayDrawer::refresh::ha1a836a76bdd18d2
                               at src/display/drawer.rs:187
  28:     0x5631c369fe47 - makair_control::display::drawer::DisplayDrawer::run::h8c46268ffdd7b1be
                               at src/display/drawer.rs:155
  29:     0x5631c372acd2 - makair_control::display::window::DisplayWindow::spawn::hf38a627defad62fc
                               at src/display/window.rs:68
  30:     0x5631c3664712 - makair_control::main::hbb2901467c3069b1
                               at src/main.rs:106
  31:     0x5631c370511b - std::rt::lang_start::{{closure}}::hb7d0472ed08cec9c
                               at /rustc/4fb7144ed159f94491249e86d5bbd033b5d60550/src/libstd/rt.rs:67
  32:     0x5631c3f466f3 - std::rt::lang_start_internal::{{closure}}::hc0a1280e68ffc5da
                               at src/libstd/rt.rs:52
  33:     0x5631c3f466f3 - std::panicking::try::do_call::h1d43a4d29f303ef5
                               at src/libstd/panicking.rs:303
  34:     0x5631c3f4a937 - __rust_maybe_catch_panic
                               at src/libpanic_unwind/lib.rs:86
  35:     0x5631c3f4721c - std::panicking::try::h5ef738612ab0072d
                               at src/libstd/panicking.rs:281
  36:     0x5631c3f4721c - std::panic::catch_unwind::h1df9a04c7f1c6fc3
                               at src/libstd/panic.rs:394
  37:     0x5631c3f4721c - std::rt::lang_start_internal::h97d4af4643f4b0e4
                               at src/libstd/rt.rs:51
  38:     0x5631c37050f7 - std::rt::lang_start::h2d79c423b97f0fc4
                               at /rustc/4fb7144ed159f94491249e86d5bbd033b5d60550/src/libstd/rt.rs:67
  39:     0x5631c36648ea - main
  40:     0x7f6334810023 - __libc_start_main
  41:     0x5631c36261be - _start
  42:                0x0 - <unknown>

Thanks for your time :)

@BlackYoup BlackYoup added the bug Something isn't working label Apr 25, 2020
@BlackYoup
Copy link
Author

BlackYoup commented Apr 25, 2020

You can now trigger the bug by cloning the repo, changing the stroke_width to 2 and cd src/software/control && cargo run -- -f ../telemetry/records/from_boot_with_fake_cycles_and_params_changes. It should take ~20 seconds to trigger

BlackYoup added a commit to makers-for-life/makair that referenced this issue Apr 27, 2020
@38
Copy link
Member

38 commented Apr 28, 2020

Thank you for reporting this, I believe I have this issue fixed on master branch.

Could you please verify the fix and really appreciate for your help.

BTW, thank you so much on working on this ventilator project at this special time :)

Cheers!

@BlackYoup
Copy link
Author

Hello,

Thanks for your patch! It seems to fix the crash :)

Do you think a new release is possible or should we just use the git resolver pinned to this commit for the time being?

@38
Copy link
Member

38 commented Apr 28, 2020

Sure, I am going to clean up the master branch and release a new minor release in a few days. I will let you know once I ship the next release. :)

@BlackYoup
Copy link
Author

Awesome, thanks!

Keruspe pushed a commit to makers-for-life/makair-control-ui that referenced this issue May 2, 2020
Keruspe pushed a commit to makers-for-life/makair-control-ui that referenced this issue May 2, 2020
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