Closed
Description
Describe the bug
When using Rust nightly compiler, attempting to draw a line is likely to cause a panic (depending on color / line coordinates):
thread 'main' panicked at 'misaligned pointer dereference: address must be a multiple of 0x8 but is 0x1ab590c7fd3', [redacted]\plotters-bitmap-0.3.2\src\bitmap_pixel\rgb.rs:215:29
The offending line is:
I believe the relevant Nightly change is rust-lang/rust#98112, but this seems to be a plotters bug and not a rustc regression (from my limited understanding).
To Reproduce
use plotters::prelude::*;
fn main() {
let mut backend = BitMapBackend::new("test.png", (256, 256));
backend.draw_line((1, 0), (100, 0), &RED).unwrap();
}
Sample project: https://github.com/agersant/plotter-panic
Version Information
Plotters 0.3.4
Activity
nbdd0121 commentedon Apr 5, 2023
That code does seem very broken:
(u64, u64, u64)
does not have any layout guarantees.ptr
comes from*mut [u8; 24]
, which doesn't have the correct alignment for u64.pbdeuchler commentedon Apr 11, 2023
I'm hitting this as well, but only when plotting a line series with a certain number of data points... i.e. purely adding more points to the same exact line "fixes" the issue.
noahdahlman commentedon Apr 17, 2023
I'm getting this as well, most of the examples I tried in the docs fail when using bitmap backend. I tried this example in a sample project and always got a panic, no issues when switching to SVG backend. Only fails on nightly (I'm using
nightly-x86_64-unknown-linux-gnu
), stable works fine.Berrysoft commentedon Apr 20, 2023
I also trigger this issue when trying to use plotters with slint with nightly toolchain. Anyway this code is broken, because you should use write_unaligned.
v0.3.5
is not published on Crates.io #453jayvdb commentedon Jun 1, 2023
This now occurs on stable v1.70
Berrysoft commentedon Jun 3, 2023
We need a new release.
ktjd123 commentedon Jun 8, 2023
I'm having error at
blend_rect_fast
😭plotters-bitmap
#478border_style
. #479