▲ | AndyKelley 5 days ago | |||||||
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. | ||||||||
▲ | dan-robertson 5 days ago | parent | next [-] | |||||||
I think the answer in your example is that when you cast the int into a pointer, it won’t have any capabilities (the other big Fil-C feature?) and therefore you can’t access memory through it. | ||||||||
| ||||||||
▲ | cgh 4 days ago | parent | prev [-] | |||||||
To expand on the capabilities thing: https://fil-c.org/invisicaps_by_example In particular, check out the sections called "Laundering Pointers As Integers" and "Laundering Integers As Pointers". | ||||||||
|