Re: [PATCH 06/10] rust: xarray: simplify `Guard::load`

From: Andreas Hindborg
Date: Wed Jan 07 2026 - 17:39:06 EST


Tamir Duberstein <tamird@xxxxxxxxx> writes:

> On Wed, Dec 3, 2025 at 5:27 PM Andreas Hindborg <a.hindborg@xxxxxxxxxx> wrote:
>>
>> Simplify the implementation by removing the closure-based API from
>> `Guard::load` in favor of returning `Option<NonNull<c_void>>` directly.
>
> This is not sound. The returned pointer can now outlive the guard and
> mutation through that pointer is trivial.

I don't think this is unsound. If we returned a reference instead, it
would be, but we are returning a raw pointer. Dereferencing the pointer
is unsafe and requires proper safety comments.


Best regards,
Andreas Hindborg