Skip to content

Violating soundness requirements #10

@SSheldon

Description

@SSheldon

Treating Foundation objects as rust references is hard. Currently this crate can be used to violate soundness rules within safe code, which could result in undefined behavior.

One problem right now comes from NSCopying:

let mut string1 = NSString::from_str("Hello, world!");
let string2 = string1.copy();

let s1: &mut NSString = &mut string1;
let s2: &NSString = &string2;
println!("{:p}", s1);
println!("{:p}", s2);

This code results in an owned Id and a ShareId of the same object, allowing an &mut reference to an address while a & reference exists for the same address. This violates the aliasing requirements.

It may be the case that it's just too difficult to safely treat Objective-C objects as rust references and this crate is a failed experiment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions