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

Coercion bypasses DistributedSlice typecheck #82

Closed
CAD97 opened this issue Mar 6, 2024 · 0 comments · Fixed by #83
Closed

Coercion bypasses DistributedSlice typecheck #82

CAD97 opened this issue Mar 6, 2024 · 0 comments · Fixed by #83

Comments

@CAD97
Copy link
Contributor

CAD97 commented Mar 6, 2024

Reproduction:

#[distributed_slice]
pub static SLICE: [&'static str];

#[distributed_slice(SLICE)]
static ELEMENT1: &&str = &"uhoh";

#[distributed_slice(SLICE)]
static ELEMENT2: &&str = &"ohno";

fn main() {
    eprintln!("{:?}", SLICE[0].as_bytes().as_ptr_range());
    // Possible output: 0x7ff75a903c88..0xffeeb5207928
    // That's 140 TB of memory just available to read
}

Culprit: DistributedSlice::private_typecheck(self, T) accepts an argument of type &&str and coerces it to &str.

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 a pull request may close this issue.

1 participant