3 ms·
A segfault implies a pointer to an unmapped page in memory. An array out of bounds error isn't the same class of error. The former implies that what pointers ca
by barrkel 11y ago
A segfault implies a pointer to an unmapped page in memory. An array out of bounds error isn't the same class of error. The former implies that what pointers can point at isn't constrained; instead of pointing at unmapped page, it could point at the inside of some sensitive data structure (think: web response buffer pointing at database credentials). The latter implies that indirections are checked; this is a very different guarantee.
- bogomipz 11y agoThanks, could you explain the "indirections" in this context? I haven't heard this before.
- barrkel 11y agoArray accesses are implicit indirections. The base, index and element size are used to compute the address of a location which is then indirected to store or load. Without range checking, array accesses can be used to read or write arbitrary locations in memory, just like pointers.
- bogomipz 11y agoAh ok right, that makes perfect sense. Thanks.