News for hackers. Stuff that matters.
Re:Linear Address Spaces: Unsafe at any speed by anonymoushn on Thursday June 30, 2022 @04:28AM (#31929993)
The part of this that I most enjoy is that you cannot even obtain some memory from your own allocator implemented on top of mmap or on top of malloc, store ints in it, return it to the allocator, ask the allocator for memory again and receive the same memory back, and store doubles in it.
Re:Linear Address Spaces: Unsafe at any speed by gpderetta on Thursday June 30, 2022 @05:28AM (#31930305)
Yes, notoriously you can't implement malloc in portable C.

In C++, I think they added enough magic in that you should now be able to do it (placement new, std::launder and numerous other hacks).

Re:Linear Address Spaces: Unsafe at any speed by rkangel on Thursday June 30, 2022 @11:15AM (#31933563)
I've implemented a pools allocator for embedded devices a couple of times. Allocating memory for callers out of a block of static memory. I thought it was portable C. Which detail of the standard did I not realise I was running into?
Re:Linear Address Spaces: Unsafe at any speed by gpderetta on Thursday June 30, 2022 @02:23PM (#31936457)
I assume the block of static memory was a large static char array.

My understanding that reusing the storage would violate the aliasing rules[1] and the rules against overlapping object lifetimes.

[1] while char ptrs can be used to access everything, the reverse is not allowed.

Re:Linear Address Spaces: Unsafe at any speed by teddyh on Thursday June 30, 2022 @09:29AM (#31932101)
Reportedly you can implement malloc in C, using mmap().
Re:Linear Address Spaces: Unsafe at any speed by gpderetta on Thursday June 30, 2022 @09:35AM (#31932165)
well mmap is posix, not standard portable C.