3 ms·
> Looking forward to this one, specially since Annex K ( Bounds Checking Interfaces) has proven to have not solved anything and is now scheduled for possible re
by rurban 8y ago
> Looking forward to this one, specially since Annex K ( Bounds Checking Interfaces) has proven to have not solved anything and is now scheduled for possible removal.
It has solved the usual bounds errors on those who use it. I.e MS, Embarcadero and safeclib. Since glibc, musl and freebsd libc refuse to use the Annex K it's easy to blame just them, not the safe extension, which do serve their goal.
With safeclib you even get compile-time checks, more than with the simple _FORTIFY_SOURCE=2 checks. Only Android Bionic got a bit better lately. safeclib is as fast or even faster than the fragile assembler bits in glibc.
> Add a new calling conventions with error return for library functions that avoids the use of errno
That's of course part of Annex K.
What's urgently missing is still a proper string API. ASCII str* goes nowhere, wide char wcs* is not widely used, 80% use utf8. wcslwr, wcsfc, wcsnorm are even missing. The whole u8* string API is missing, and not even discussed. ICU, libutf8 and libunistring don't get you far. coreutils still cannot handle non-ASCII strings.
- pjmlp 8y agoNot at all, because it doesn't fix out of bounds errors caused by copy-paste errors where the given buffer size doesn't match the actual size of the declared buffer or string. A situation which is described on the field report I linked to. Only C++ compilers like Visual C++ which provide overloaded versions of Annex K without size parameter thanks to the improved C++ type system, do actually provide a real usable version of Annex K. But then it isn't C anylonger.
- rurban 8y ago> Not at all, because it doesn't fix out of bounds errors caused by copy-paste errors where the given buffer size doesn't match the actual size of the declared buffer or string. That's wrong, check the implementation. C++ only has advantages because there g++ is not as broken as gcc with constexpr, but clang since 5.0 is doing fine. https://github.com/rurban/safeclib https://github.com/rurban/safeclib
- pjmlp 8y agoAs you mention on "Compile-time constraints" this extensions to Annex K require a supporting compiler. It is perfectly viable to have a 100% ISO C99/C11 compliant compiler that will happily overwrite the target buffer, read more bytes than actually exist or search the whole memory block for a '\0' terminator, because Annex K does not require the existence of the compiler extensions used by your safeclib.
- rurban 8y agoRight. Microsoft does it wrong. But neither ISP nor POSIX require _FORTIFY_SOURCE neither which uses the same object_size (bos) CHECKS. The alloc_size builtin or the CPU supported bounds checks are not used at all with the major libc's. Problem is not the Annex K, but the refusal to implement and use it. There's no problem with state as in errno or locale. The criticism is easily debunkable. It's outright NIH bias.
- pjmlp 8y agoWhat I would like to see would be tagged memory like the SPARC has, which was put to good effect on Solaris, to become common across all major platforms. Apparently at least Android might adopt it on ARM. And do concede, maybe the extensions you have used, to actually become part of Annex K as well instead of deprecating it. Because despite my dislike for C, I am fully aware that UNIX derived platforms will stay with us for the years to come, so we need to improve the current state of affairs somehow.