Hacker News new | past | comments | ask | show | jobs | submit login

If only we could guarantee immediate segfaults.



That's literally what Rust compiler errors are doing. :P


> If only we could guarantee immediate segfaults.

It should be possible to create a malloc implementation that does that by making the minimum allocation size a page and then not reusing virtual addresses for new allocations. Then once an allocation is freed, any access to it is permanently a segfault.

That may not be practical on existing architectures with 48-bit virtual addressing though, since you could plausibly exhaust the address space. The full 64 bits might be sufficient for most things at least.

You could also get most of the benefit by not reusing virtual addresses until you run out.


It's not, because that relies on actually doing the de-reference. Thanks to UB, that may never actually happen, the code may get removed entirely.


If the code is removed entirely then what memory is being improperly accessed?


It's impossible to tell, as that can cause other issues. See the link I posted about time travel elsewhere in the thread.


The day will come when the compilers that do things like that will be righteously categorized as malware.


The day will come when language specifications that allow compilers to do things like that will be righteously categorized as archaic.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: