-
Notifications
You must be signed in to change notification settings - Fork 281
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] Drawing series can hang under certain conditions #562
Comments
I have the same problem. It happens to be the case that I tracked that infinity back to this section. plotters/plotters-backend/src/rasterizer/path.rs Lines 64 to 87 in 123764a
In some cases, you fail both the check on line 68 and 76, and then it computes a vertex to be placed at infinity. I am not sure if this should have been cought in some preconditions or so... Or if it is a plain bug. |
@JuliDi I took your code and simplified further. My most minimal reproduction is as per below. use plotters::prelude::*;
pub fn main() -> Result<(), Box<dyn std::error::Error>> {
let root = BitMapBackend::new("test.bmp", (1000, 1000)).into_drawing_area();
let mut chart = ChartBuilder::on(&root)
.build_cartesian_2d(0.0..1000.0, 0.0..1000.0)?;
let data = [(336.0, 614.0), (339.0, 674.0),(341.0,714.0)];
chart.draw_series(std::iter::once(PathElement::new(
data,
ShapeStyle::from(RED).stroke_width(2),
)))?;
Ok(())
} Drawing an AreaSeries will create an outline (you asked for a border of thickness 2) and this triggers drawing a PathElement under the hood. When asking for a thickness > 1, it will call A workaround could be to use border thickness 1. |
Okay, after some more debugging, I think I got it. It seems like a classical float-comparison bug. I'll try to create a fix. |
@el-hult thanks for looking into this! |
My fix is in the referenced pull request. Lets hope they merge it. |
Thank you! |
This issue can probably be closed as fixed now after merge. |
Describe the bug
Using the code in the following repo, plotters will hang when drawing the series. It only happens under very specific conditions, i.e., the specifically set stroke width and backend dimensions with a certain dataset.
It looks like there is something going on with an over-/underflow because when the bug occurs, the
vertices
vector has at least once the values(2147483647, 2147483647)
, which cause thex_span
hereplotters/plotters-backend/src/rasterizer/polygon.rs
Line 124 in af0b63c
I am not sure where these might come from and wasn't able to pinpoint the exact issue with the debugger.
To Reproduce
The code to reproduce the issue can be found here for convenience: https://github.com/JuliDi/plotters-bug-demo including a set of data that triggers the bug.
Details
Version Information
Latest master branch, commit af0b63c
The text was updated successfully, but these errors were encountered: