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

Bail out from rendering when bitmap_buffer is null #197

Merged
merged 1 commit into from May 25, 2023

Conversation

saethlin
Copy link
Contributor

@saethlin saethlin commented Jun 18, 2022

I don't really understand what's going on here. All I really know is that I ran into one of the standard library's debug assertions when running some of the examples in plotters. I trimmed one down, but not a whole lot.

use plotters::prelude::*;
fn main() {
    let mut buffer = vec![0u8; 1024 * 768 * 3];
    let area = BitMapBackend::with_buffer(&mut buffer[..], (1024, 768))
        .into_drawing_area()
        .split_evenly((1, 2));
    let _chart = ChartBuilder::on(&area[0])
        .caption("Incremental Example", ("sans-serif", 20))
        .build_cartesian_2d(0..10, 0..10)
        .expect("Unable to build ChartContext");
}

Running this example without this patch using cargo +nightly run -Zbuild-std --target=x86_64-unknown-linux-gnu will panic:

thread 'main' panicked at 'unsafe precondition(s) violated: slice::from_raw_parts requires the pointer to be aligned and non-null, and the total size of the slice not to exceed `isize::MAX`', /home/ben/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/panicking.rs:126:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread caused non-unwinding panic. aborting.
Aborted (core dumped)

The problem is that the pointer is null.

@Manishearth
Copy link
Member

@bors r+

Seems like an okay fix, though I'm not that clear on this codebase

@jdm
Copy link
Member

jdm commented May 24, 2023

@bors-servo r+

@bors-servo
Copy link
Contributor

📌 Commit 3bb66f3 has been approved by jdm

@bors-servo
Copy link
Contributor

⌛ Testing commit 3bb66f3 with merge 4811bef...

bors-servo added a commit that referenced this pull request May 24, 2023
Bail out from rendering when bitmap_buffer is null

I don't really understand what's going on here. All I really know is that I ran into one of the standard library's debug assertions when running some of the examples in `plotters`. I trimmed one down, but not a whole lot.

```rust
use plotters::prelude::*;
fn main() {
    let mut buffer = vec![0u8; 1024 * 768 * 3];
    let area = BitMapBackend::with_buffer(&mut buffer[..], (1024, 768))
        .into_drawing_area()
        .split_evenly((1, 2));
    let _chart = ChartBuilder::on(&area[0])
        .caption("Incremental Example", ("sans-serif", 20))
        .build_cartesian_2d(0..10, 0..10)
        .expect("Unable to build ChartContext");
}
```
Running this example without this patch using `cargo +nightly run -Zbuild-std --target=x86_64-unknown-linux-gnu` will panic:
```
thread 'main' panicked at 'unsafe precondition(s) violated: slice::from_raw_parts requires the pointer to be aligned and non-null, and the total size of the slice not to exceed `isize::MAX`', /home/ben/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/panicking.rs:126:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread caused non-unwinding panic. aborting.
Aborted (core dumped)
```
The problem is that the pointer is null.
@Manishearth
Copy link
Member

Needs a rustfmt run

@bors-servo
Copy link
Contributor

💥 Test timed out

@Manishearth
Copy link
Member

@bors-servo r+

@bors-servo
Copy link
Contributor

📌 Commit 787b68f has been approved by Manishearth

@bors-servo
Copy link
Contributor

⌛ Testing commit 787b68f with merge 8a714dd...

bors-servo added a commit that referenced this pull request May 24, 2023
Bail out from rendering when bitmap_buffer is null

I don't really understand what's going on here. All I really know is that I ran into one of the standard library's debug assertions when running some of the examples in `plotters`. I trimmed one down, but not a whole lot.

```rust
use plotters::prelude::*;
fn main() {
    let mut buffer = vec![0u8; 1024 * 768 * 3];
    let area = BitMapBackend::with_buffer(&mut buffer[..], (1024, 768))
        .into_drawing_area()
        .split_evenly((1, 2));
    let _chart = ChartBuilder::on(&area[0])
        .caption("Incremental Example", ("sans-serif", 20))
        .build_cartesian_2d(0..10, 0..10)
        .expect("Unable to build ChartContext");
}
```
Running this example without this patch using `cargo +nightly run -Zbuild-std --target=x86_64-unknown-linux-gnu` will panic:
```
thread 'main' panicked at 'unsafe precondition(s) violated: slice::from_raw_parts requires the pointer to be aligned and non-null, and the total size of the slice not to exceed `isize::MAX`', /home/ben/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/panicking.rs:126:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread caused non-unwinding panic. aborting.
Aborted (core dumped)
```
The problem is that the pointer is null.
@bors-servo
Copy link
Contributor

💥 Test timed out

@Manishearth Manishearth merged commit d183178 into servo:master May 25, 2023
2 of 4 checks passed
@Manishearth
Copy link
Member

Something wrong with macos builders

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants