Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AddressSanitizer false positive #9

Open
MarkReedZ opened this issue Sep 18, 2018 · 1 comment
Open

AddressSanitizer false positive #9

MarkReedZ opened this issue Sep 18, 2018 · 1 comment

Comments

@MarkReedZ
Copy link
Owner

Building with the address sanitizer gives I believe a false error when you access a page on the site. In the code we're using cmpestri pointing to a staticly initialized array along with a length of that array. The complaint occurs because of the 128bit load I believe when the array is smaller than that.

I assume we can get rid of this error by initializing all occurrences of static char ranges with the full length expected by the load but haven't tried it and am not sure of the performance impact if any. Also can we use an aligned load?

CFLAGS='-Wall -O0 -g -fsanitize=address -fno-omit-frame-pointer -fsanitize-recover=address' python setup.py install --force
ASAN_OPTIONS=halt_on_error=0 LD_PRELOAD=/usr/lib/gcc/x86_64-linux-gnu/7/libasan.so python tst.py

==15521==ERROR: AddressSanitizer: global-buffer-overflow on address 0x7f18aa246b20 at pc 0x7f18aa011b7a bp 0x7ffd42ea2910 sp 0x7ffd42ea2900
READ of size 16 at 0x7f18aa246b20 thread T0
    #0 0x7f18aa011b79 in _mm_loadu_si128 /usr/lib/gcc/x86_64-linux-gnu/7/include/emmintrin.h:702
    #1 0x7f18aa011b79 in findchar_fast src/mrhttp/internals/request.c:158

// ranges that is loaded
  static char ranges1[] = "%%" "??";

// This just points to ranges1
        __m128i ranges16 = _mm_loadu_si128((const __m128i *)ranges);

// _mm_cmpestri takes a size so it doesn't got beyond the length of the array passed in.
            int r = _mm_cmpestri(ranges16, ranges_size, b16, 16, _SIDD_LEAST_SIGNIFICANT | _SIDD_CMP_RANGES | _SIDD_UBYTE_OPS);

@MarkReedZ
Copy link
Owner Author

I'm pretty sure simply setting the array length will fix this.

static char ranges1[16] = "%%" "??";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant