[compiler-rt] Make the MSAN wmemset intercepter call wmemset instead of memset. Fixes PR 21579

Summary:
Exactly what the title says. I've tested this change against the libc++ test failures and it solves all of them. The check-msan rule also still passes.
I'm not sure why it called memset originally. 

I can add tests if requested but currently there are no tests involving wide chars and they are a c++11 features.

Reviewers: kcc, eugenis

Reviewed By: eugenis

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D6352

llvm-svn: 222673
This commit is contained in:
Eric Fiselier 2014-11-24 18:17:04 +00:00
parent a69bcd5ed0
commit 909deebfc8
2 changed files with 11 additions and 1 deletions

View File

@ -531,7 +531,7 @@ INTERCEPTOR(wchar_t *, wmempcpy, wchar_t *dest, const wchar_t *src, SIZE_T n) {
INTERCEPTOR(wchar_t *, wmemset, wchar_t *s, wchar_t c, SIZE_T n) { INTERCEPTOR(wchar_t *, wmemset, wchar_t *s, wchar_t c, SIZE_T n) {
CHECK(MEM_IS_APP(s)); CHECK(MEM_IS_APP(s));
ENSURE_MSAN_INITED(); ENSURE_MSAN_INITED();
wchar_t *res = (wchar_t *)REAL(memset)(s, c, n * sizeof(wchar_t)); wchar_t *res = REAL(wmemset)(s, c, n);
__msan_unpoison(s, n * sizeof(wchar_t)); __msan_unpoison(s, n * sizeof(wchar_t));
return res; return res;
} }

View File

@ -1834,6 +1834,16 @@ TEST(MemorySanitizer, wcsnrtombs) {
EXPECT_POISONED(buff[2]); EXPECT_POISONED(buff[2]);
} }
TEST(MemorySanitizer, wmemset) {
wchar_t x[25];
break_optimization(x);
EXPECT_POISONED(x[0]);
wmemset(x, L'A', 10);
EXPECT_EQ(x[0], L'A');
EXPECT_EQ(x[9], L'A');
EXPECT_POISONED(x[10]);
}
TEST(MemorySanitizer, mbtowc) { TEST(MemorySanitizer, mbtowc) {
const char *x = "abc"; const char *x = "abc";
wchar_t wx; wchar_t wx;