3 ms·
The most important helping feature of an ISA is to provide an efficient way to compare indices and pointers against limits, so that the poor performance of limi
by adrian_b 4y ago
The most important helping feature of an ISA is to provide an efficient way to compare indices and pointers against limits, so that the poor performance of limits checking will not discourage the compiler writers and the compiler users to always make such checks.
Any decent C/C++ compiler has compile options to check all array accesses against limits, which, coupled with the good programming practice of always using indices and not pointers for memory accesses, can catch all the programming errors of the buffer overflow type.
However, neither the compilers enable this option by default nor most programmers take care to always enable it, because of usually baseless worries of degrading the performance.
Checking accesses against limits catches any such bugs at their origin, not much later when a corrupt pointer is identified by PAC, without knowing how it became corrupt.
Intel has made an attempt with Skylake to introduce some instructions for easier limits checking, but unfortunately the instructions conceived by them were just dumb and not helpful at all, so they have been eventually deprecated.
Better support exists in the IBM POWER ISA, which has conditional trap instructions.