[libc-commits] [PATCH] D77949: [libc] Add SIMD strlen implementation .

Alex Brachet via Phabricator via libc-commits libc-commits at lists.llvm.org
Sat Apr 11 10:39:48 PDT 2020


abrachet added a comment.

As a high level comment, this scheme is technically safe because no mmu that I know of can deal make fault pages on non word boundaries (of course they all do at page boundaries) so readying some extra bytes past the end of the string will never cause SIGBUS or SIGSEGV. However it is still undefined behavior and sanitizers will complain. If you build with `LLVM_USE_SANITIZER=Address` I'm pretty sure that `FourBytes` and `TwoBytes` will fail. And certainly `__llvm_libc::strlen(__llvm_libc::strcpy(::malloc(6), "12345"));` will get the sanitizers to complain.

I think it is worth discussing if we think it's valuable to turn off sanitizers for this function because we can conclude that it is safe to read past the string in the name of speed. I'd like to hear what the others have to say.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77949/new/

https://reviews.llvm.org/D77949





More information about the libc-commits mailing list