News for hackers. Stuff that matters.
Re:Memory Safety Without Borrow Checking, Reference Counting... by tgv on Friday June 16, 2023 @07:08AM (#36354606)
> There doesn't look like there's actually anything preventing the user from calling free themselves

True, but wouldn't that still be memory safe? It seems to me that it could lead to a memory leak, but not to double use of memory. But another annotation to the type so that free() can only be called at one point (or perhaps a few points) might solve that.

Re:Memory Safety Without Borrow Checking, Reference Counting... by dwattttt on Friday June 16, 2023 @07:45AM (#36354926)
An adversary can turn a double free into a use after free by causing an object to be allocated in-between the two free operations at the same address
Re:Memory Safety Without Borrow Checking, Reference Counting... by tgv on Friday June 16, 2023 @09:25AM (#36356213)
You can't free a buffer/object twice in the proposal. After a free, you can't use the pointer any longer.

But it might very well be that this approach is not hard enough for use in e.g. the kernel. It might still be useful for userland applications, though.

Re:Memory Safety Without Borrow Checking, Reference Counting... by chc4 on Friday June 16, 2023 @08:00AM (#36355104)
It doesn't leak memory, but the example use case of "high RAII" isn't about not leaking memory but that "the compiler can ensure you remember to do something in the future and don't accidentally forget it" and "remember to remove something from a cache that you previously added to" - which isn't actually done, because the consumer can call free and the data will still erroneously be in a cache, for example.