harfbuzz / harfbuzz/harfbuzz_rs
"unsafe precondition(s) violated" querying tables from "Apple Color Emoji"
- Dominant language
- Rust
- Stars
- 64
- Forks
- 25
- PR merge metrics
- No merged PRs in 30d
Description
This code panics on macOS:
```rust
use std::sync::Arc;
fn main() {
let (font, i) = find_system_font("Apple Color Emoji");
let face = harfbuzz_rs::Face::from_bytes(&font, i);
let _ = face.table_with_tag(b"GSUB").is_some();
}
fn find_system_font(name: &str) -> (Arc>, u32) {
let font = font_kit::source::SystemSource::new()
.select_best_match(
&[font_kit::family_name::FamilyName::Title(name.to_owned())],
&font_kit::properties::Properties::new(),
)
.unwrap();
match font {
font_kit::handle::Handle::Path { .. } => panic!("did not expect path"),
font_kit::handle::Handle::Memory { bytes, font_index } => (bytes, font_index),
}
}
```
Panic:
```
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`
stack backtrace:
0: rust_begin_unwind
at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:645:5
1: core::panicking::panic_nounwind_fmt::runtime
at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/panicking.rs:110:18
2: core::panicking::panic_nounwind_fmt
at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/panicking.rs:123:9
3: core::panicking::panic_nounwind
at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/panicking.rs:156:5
4: core::slice::raw::from_raw_parts::precondition_check
5: core::slice::raw::from_raw_parts
6: harfbuzz_rs::blob::Blob::get_data
7: ::deref
8: harfbuzz_rs::face::Face::table_with_tag
9: harfbuzz_issue::main
10: core::ops::function::FnOnce::call_once
```
I think "Apple Color Emoji" does not have `GSUB`, so I expected `false` there.
---
I first encountered the issue here:
Minimized issue crate here:
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.