Skip to content

Zerovec DST construction fails miri (Zerovec should use pointer metadata APIs) #6723

@DarthB

Description

@DarthB

Miri is complaining on CaseMapper::fold_string. It says that it is an experimental rule; nonetheless, this ruins confidence.

  • Did someone use CaseMapper::fold_string() on many data points and has therefore more confidence?
  • As far as I understand this is related to zerocopy with zerovec maybe there have been similar issues?

How to reproduce

When running the code below with icu 2.0.0 with miri: cargo +nightly miri run. You'll get the attached error description.

use icu::casemap::CaseMapper;
fn main() {
    let cm = CaseMapper::new();
    let result = cm.fold_string("Test");
    println!("{}", result);
}
error: Undefined Behavior: trying to retag from <7066> for SharedReadOnly permission at alloc735[0x31b], but that tag does not exist in the borrow stack for this location
  --> /Users/darthb/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/icu_casemap-2.0.0/src/provider/exceptions.rs:89:1
   |
89 | #[zerovec::make_varule(ExceptionULE)]
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   | |
   | trying to retag from <7066> for SharedReadOnly permission at alloc735[0x31b], but that tag does not exist in the borrow stack for this location
   | this error occurs as part of retag at alloc735[0x318..0x31d]
   |
   = help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
   = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
help: <7066> was created by a SharedReadOnly retag at offsets [0x318..0x31b]
  --> src/main.rs:11:18
   |
11 |     let result = cm.fold_string("Test");
   |                  ^^^^^^^^^^^^^^^^^^^^^^
   = note: BACKTRACE (of the first span):
   = note: inside `<icu::icu_casemap::provider::exceptions::ExceptionULE as zerovec::ule::VarULE>::from_bytes_unchecked` at /Users/darthb/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/icu_casemap-2.0.0/src/provider/exceptions.rs:89:1: 89:38
   = note: inside `zerovec::varzerovec::components::VarZeroVecComponents::<'_, icu::icu_casemap::provider::exceptions::ExceptionULE, zerovec::varzerovec::components::Index16>::get_unchecked` at /Users/darthb/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/zerovec-0.11.2/src/varzerovec/components.rs:394:9: 394:46
   = note: inside `zerovec::varzerovec::components::VarZeroVecComponents::<'_, icu::icu_casemap::provider::exceptions::ExceptionULE, zerovec::varzerovec::components::Index16>::get` at /Users/darthb/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/zerovec-0.11.2/src/varzerovec/components.rs:383:23: 383:46
   = note: inside `zerovec::varzerovec::slice::VarZeroSlice::<icu::icu_casemap::provider::exceptions::ExceptionULE>::get` at /Users/darthb/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/zerovec-0.11.2/src/varzerovec/slice.rs:202:9: 202:38
   = note: inside `icu::icu_casemap::provider::exceptions::CaseMapExceptions::<'_>::get` at /Users/darthb/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/icu_casemap-2.0.0/src/provider/exceptions.rs:53:25: 53:56
   = note: inside `icu::icu_casemap::internals::<impl icu::icu_casemap::provider::CaseMap<'_>>::full_helper::<false, writeable::to_string_or_borrow::SliceOrString<'_>>` at /Users/darthb/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/icu_casemap-2.0.0/src/internals.rs:343:29: 343:53
   = note: inside `<icu::icu_casemap::internals::FullCaseWriteable<'_, '_, false> as writeable::Writeable>::write_to::<writeable::to_string_or_borrow::SliceOrString<'_>>` at /Users/darthb/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/icu_casemap-2.0.0/src/internals.rs:71:13: 72:92
   = note: inside `writeable::to_string_or_borrow::to_string_or_borrow::<icu::icu_casemap::internals::FullCaseWriteable<'_, '_, false>>` at /Users/darthb/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/writeable-0.6.1/src/to_string_or_borrow.rs:208:13: 208:42
   = note: inside `icu::icu_casemap::CaseMapperBorrowed::<'_>::fold_string` at /Users/darthb/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/icu_casemap-2.0.0/src/casemapper.rs:401:9: 401:72
note: inside `main`
  --> src/main.rs:11:18
   |
11 |     let result = cm.fold_string("Test");
   |                  ^^^^^^^^^^^^^^^^^^^^^^
   = note: this error originates in the attribute macro `zerovec::make_varule` (in Nightly builds, run with -Z macro-backtrace for more info)

note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

error: aborting due to 1 previous error

Metadata

Metadata

Assignees

Labels

C-zerovecComponent: Yoke, ZeroVec, DataBake

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions