-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
This version of strlen() handles 16 Bytes per iteration, as the comments tell:
https://github.com/bavison/arm-mem/blob/master/strlen-v7l.S
10: /* Handle 16 SIMD bytes per iteration until we hit a load that crosses a page boundary */
/* Loop rotated so that termination test is in what would otherwise be a stall */
vld1.8 {d0,d1}, [PTR :64]!
Unfortunately, this code does not handle the case that a buffer might be smaller than 16 bytes.
When I allocated an 8 byte buffer and ran strlen() on if, the above assembly instruction triggered the valgrind message
==3652== Invalid read of size 8
==3652== at 0x48531DC: ??? (in /usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so)
I double-checked this by overriding strlen() with the following primitive implementation:
#if 01
#undef strlen
#define strlen my_strlen
extern size_t my_strlen(char const *s) {
size_t len;
for (len = 0; s[len] != 0; ++len) {}
return len;
}
#endif
Valgrind then did no longer report any invalid memory accesses.
I assume this bug also covers the issue reported in #13.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels