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

MemorySanitizer false positive with _mm_cmpneq_sd #678

Closed
eugenis opened this issue Apr 28, 2016 · 2 comments
Closed

MemorySanitizer false positive with _mm_cmpneq_sd #678

eugenis opened this issue Apr 28, 2016 · 2 comments

Comments

@eugenis
Copy link
Contributor

eugenis commented Apr 28, 2016

$ cat 1.cc

include <emmintrin.h>

__m128d f(double a, double b) {
__m128d v = _mm_cmpneq_sd(_mm_load_sd(&a), _mm_load_sd(&b));
return v;
}

int main() {
double a = 1.;
double b = 2.;
double * volatile pa = &a;
double * volatile pb = &b;
__m128d c = f(a, b);
return c[0] + c[1];
}

$ ./bin/clang++ ../llvm/1.cc -fsanitize=memory -O1 -g && PATH=bin:$PATH ./a.out
==32151==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x4863e7 in f(double, double) /code/build-llvm/../llvm/1.cc:4:15
#1 0x4864bd in main /code/build-llvm/../llvm/1.cc:13:15

@eugenis
Copy link
Contributor Author

eugenis commented Apr 28, 2016

Ah, return c[0] + c[1] is technically incorrect, because the second half of c is garbage.
But MSan crash happens earlier anyway.

@eugenis
Copy link
Contributor Author

eugenis commented Apr 29, 2016

This should be fixed in r267966 + r267967

@eugenis eugenis closed this as completed Apr 29, 2016
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