News for hackers. Stuff that matters.
Re:The Arm64 memory tagging extension in Linux by jackewiehose on Monday October 19, 2020 @08:02AM (#24825532)
Using pointers for sorting is fine as long as you don't care about the order (parent referenced std::set and it's not uncommon to use a set of pointers if you just want to store some objects). Likewise it's fine to use pointers for equality-comparisons as long as the pointer is valid (of course you have to dismiss the pointer when the memory is freed).

I'm pretty sure this memory extension doesn't affect uniqueness of pointers... that would indeed break a lot of software ;-)

Re:The Arm64 memory tagging extension in Linux by flohofwoe on Monday October 19, 2020 @10:24AM (#24826638)
> uniqueness of pointers...

What I mean is for example: you get a pointer by allocating memory, then free that memory, then you allocate again and get a pointer to the same memory location. Without a tag those two pointers would be equal, even though they come from separate memory allocations. This can be a source of bugs if the pointer is also used as some sort of object id, and I know that at least I stumbled over this embarrassing problem more than once in C++ until I switched to tagged handles :)

Re:The Arm64 memory tagging extension in Linux by jackewiehose on Monday October 19, 2020 @11:12AM (#24827073)
You can use the pointer as an object id, but only for living objects. The pointer becomes invalid the moment the memory is freed. Your bug was that you used an invalid pointer.
Re:The Arm64 memory tagging extension in Linux by Matt3o12_ on Monday October 19, 2020 @11:49AM (#24827450)
But doesn't this feature exactly help with this bug? Two memory allocations should now return different pointers (because the MTE nibble is different) therefore the comparision should fail. Unless ofcourse the application was using this undefined behavior (which would be very buggy since malloc can randomly refuse to reuse the same address even though it was freed and therefore create extremely hard and difficult to track bugs).
Re:The Arm64 memory tagging extension in Linux by flohofwoe on Monday October 19, 2020 @12:00PM (#24827603)
> Your bug was that you used an invalid pointer.

Exactly, but just declaring that a pointer is "invalid" doesn't help much with debugging such dangling pointer problems, while tagged pointers do.

It's not like an "invalid pointer" is any different from a "valid pointer" when you look at it. With the extra tag bits, an invalid pointer can actually be identified as such.