▲ | pizlonator 5 days ago | |||||||||||||||||||||||||||||||||||||||||||
> given that pointers can be converted to integers? Because if they get converted to integers and then stored to the heap then they lose their capability. So accesses to them will trap and the GC doesn’t need to care about them. Also it’s not “Dijkstra accurate”. It’s a Dijkstra collector in the sense that it uses a Dijkstra barrier. And it’s an accurate collector. But these are orthogonal things | ||||||||||||||||||||||||||||||||||||||||||||
▲ | AndyKelley 5 days ago | parent | next [-] | |||||||||||||||||||||||||||||||||||||||||||
Hmm, I'm still not understanding the bit of information that I'm trying to ask about. Let's say I malloc(42) then print the address to stdout, and then do not otherwise do anything with the pointer. Ten minutes later I prompt the user for an integer, they type back the same address, and then I try to write 42 bytes to that address. What happens? Edit: ok I read up on GC literature briefly and I believe I understand the situation. "conservative" means the garbage collector does not have access to language type system information and is just guessing that every pointer sized thing in the stack is probably a pointer. "accurate" means the compiler tells the GC about pointer types, so it knows about all the pointers the type system knows about. Neither of these are capable of correctly modeling the C language semantics, which allows ptrtoint / inttoptr. So if there are any tricks being used like xor linked lists, storing extra data inside unused pointer alignment bits, or a memory allocator implementation, these will be incompatible even with an "accurate" garbage collector such as this. I should add, this is not a criticism, I'm just trying to understand the design space. It's a pretty compelling trade offer: give up ptrtoint, receive GC. | ||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||
▲ | charleslmunger 5 days ago | parent | prev [-] | |||||||||||||||||||||||||||||||||||||||||||
Out of curiosity, does this idiom work in fil-c? https://github.com/protocolbuffers/protobuf/blob/cb873c8987d...
It does use the implementation defined behavior that a char pointer + 1 casted to uintptr is the same as casting to uintptr then adding 1. | ||||||||||||||||||||||||||||||||||||||||||||
|