Skip to content

Bail out from rendering when bitmap_buffer is null#197

Merged
Manishearth merged 1 commit into
servo:masterfrom
saethlin:master
May 25, 2023
Merged

Bail out from rendering when bitmap_buffer is null#197
Manishearth merged 1 commit into
servo:masterfrom
saethlin:master

Conversation

@saethlin

@saethlin saethlin commented Jun 18, 2022

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Member

@bors r+

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

@jdm

jdm commented May 24, 2023

Copy link
Copy Markdown
Member

@bors-servo r+

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 3bb66f3 has been approved by jdm

@bors-servo

Copy link
Copy Markdown
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
Copy Markdown
Member

Needs a rustfmt run

@bors-servo

Copy link
Copy Markdown
Contributor

💥 Test timed out

@Manishearth

Copy link
Copy Markdown
Member

@bors-servo r+

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 787b68f has been approved by Manishearth

@bors-servo

Copy link
Copy Markdown
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
Copy Markdown
Contributor

💥 Test timed out

@Manishearth Manishearth merged commit d183178 into servo:master May 25, 2023
@Manishearth

Copy link
Copy Markdown
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.

4 participants