Rust SIG Meeting - 2026-08-04 #38
Replies: 11 comments 5 replies
|
Thank you all. I would be grateful if you could read the Rust Safety Standard and give us feedback. |
|
My question is: since raw pointers are not checked by the borrow checker, how is that requirement checked by this invariants (verify) ?, like it checks for ownership rule. |
|
Sorry my question was unclear or if my understanding was unclear. The example of how len was unsafe had me wondering how far this prover can go compared to languages Agda that have a full prover in the type system. I.e., it seemed the issue in the code you provided was that the user had defined Is there a way for a caller to provide proof that it maintains an invariant that the method requires ? The easiest example I can think of is a visitor to some custom sum-like type. There are better ways to accomplish this API, so just consider this for rhetorical purposes: #[rapx::invariant(any((Null(a), NotNull(b)), (NotNull(a), Null(b)))]
struct Swapper<A, B> {
pub a: *mut A,
pub b: *mut B,
}
impl<A, B> Swapper<A, B> {
fn activate_b_with_fn<S>(&mut self, f: impl FnOnce(*mut A) -> *mut B) -> &B {
if self.b.is_null() {
// implicitly requires f always produces non-null.
self.b = f(self.a);
self.a = ptr::null_mut();
}
unsafe { &*self.b }
}
}This is fine if we can prove that In essence, I'm asking a veiled question about the scope of RAPx's model/prover. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hey folks 👋 welcome to our 15th meeting of 2026.
Rust SIG Meeting 2026-08-04
Agenda
Check-in area
We had roughly xx people present at peak attendance, including those listed below.
Housekeeping
#rust-sigTasks / action items
Rust Watercooler Chat Topic: Unsafe Rust Code: From Encapsulation to Verification; Hui Xu / Fudan University
About Us: Safer-Rust (Unofficial) Working Group on Unsafe Rust
I. Example of Unsafe Code Encapsulation
Using Linked List to explain
Key point: how can we ensure that we can say that something is "safe" when it uses / calls
unsafecode?Can guarantee some properties of push_back(), may not be able to do for others.
*
Can guarantee some properties of pop_front(), may not be able to do for others.
unsafeoperationsUnsound encapsulation of front()
Questions
What about borrow checker for raw pointer in your example? I think we talked about ownership rule. For example, the borrow checker may not help with multiple references to the same raw pointer in a given code block. (@bharatGoswami8 will follow up later with a post on this thread)
Verification
Can annotate unsafe APIs with Contracts
Can then assume invariants are upheld when returning from the function
Same concept is used in Rust for Linux, but in plaintext, not machine checked
(Add more details here later)
Example code shown
For example, can annotate to ensure that copy_front() will have a bound allowing for copying the element
prepare-targetsverifyQuestion: does verify cover "all current uses" or "all possible uses" of functions?
front()
Question: So if you constrain the type by copy, RAPx will be fine with it?
The safe version has the bound for T: Copy, so then it is verified.
RAPX already reads the core/standard library docs to determine properties useful to the verification
Adoption of the standard / guidelines for unsafe (RAPX)
Two perspectives
Safety Promise of Rust
Default Soundness Criterion: Module Level (for pub APIs)
Design Choices
In the case of showing a case of potentially "incorrect" state, we could think about using
unsafeto note that you might get something "wrong"This is sometimes called "indirect" or "library" undefined behavior in the Rust Project.
How far can you get without a full prover ? I.e., how do you handle cases where the caller must provide its own proof that its maintaining some invariant on behalf of the module ?
Where are the definitions of "Aliasing" and so on?
Recent events / things coming up for Rust
xx
Requested topics
xx
Material
xx
All reactions