diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-05-03 20:26:31 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-05-03 20:26:31 +0000 |
commit | 285f392c555459b82baeec68b944936685546972 (patch) | |
tree | 859b31c183aacabb13a82a7199883a2c70f70d37 | |
parent | 8d8e909cdc9f4e78e1e1600497d827e1acde6cea (diff) | |
download | src-test2-285f392c555459b82baeec68b944936685546972.tar.gz src-test2-285f392c555459b82baeec68b944936685546972.zip |
Notes
41 files changed, 313 insertions, 44 deletions
diff --git a/include/sanitizer/tsan_interface.h b/include/sanitizer/tsan_interface.h index a0c70263895a..5ea09ab5c1ff 100644 --- a/include/sanitizer/tsan_interface.h +++ b/include/sanitizer/tsan_interface.h @@ -126,6 +126,7 @@ void __tsan_mutex_post_divert(void *addr, unsigned flags); // which is later used in read/write annotations to denote the object type // - __tsan_external_assign_tag can optionally mark a heap object with a tag void *__tsan_external_register_tag(const char *object_type); +void __tsan_external_register_header(void *tag, const char *header); void __tsan_external_assign_tag(void *addr, void *tag); void __tsan_external_read(void *addr, void *caller_pc, void *tag); void __tsan_external_write(void *addr, void *caller_pc, void *tag); diff --git a/lib/lsan/lsan_interceptors.cc b/lib/lsan/lsan_interceptors.cc index fe1f49bcdeba..9e39a7d1944d 100644 --- a/lib/lsan/lsan_interceptors.cc +++ b/lib/lsan/lsan_interceptors.cc @@ -185,6 +185,20 @@ INTERCEPTOR(void, cfree, void *p) ALIAS(WRAPPER_NAME(free)); #define LSAN_MAYBE_INTERCEPT_CFREE #endif // SANITIZER_INTERCEPT_CFREE +#if SANITIZER_INTERCEPT_MCHECK_MPROBE +INTERCEPTOR(int, mcheck, void (*abortfunc)(int mstatus)) { + return 0; +} + +INTERCEPTOR(int, mcheck_pedantic, void (*abortfunc)(int mstatus)) { + return 0; +} + +INTERCEPTOR(int, mprobe, void *ptr) { + return 0; +} +#endif // SANITIZER_INTERCEPT_MCHECK_MPROBE + #define OPERATOR_NEW_BODY \ ENSURE_LSAN_INITED; \ GET_STACK_TRACE_MALLOC; \ diff --git a/lib/sanitizer_common/sanitizer_common_interceptors.inc b/lib/sanitizer_common/sanitizer_common_interceptors.inc index 4fe1ac8f9da7..53204b48e300 100644 --- a/lib/sanitizer_common/sanitizer_common_interceptors.inc +++ b/lib/sanitizer_common/sanitizer_common_interceptors.inc @@ -6142,6 +6142,20 @@ INTERCEPTOR(int, getloadavg, double *loadavg, int nelem) { #define INIT_GETLOADAVG #endif +#if SANITIZER_INTERCEPT_MCHECK_MPROBE +INTERCEPTOR(int, mcheck, void (*abortfunc)(int mstatus)) { + return 0; +} + +INTERCEPTOR(int, mcheck_pedantic, void (*abortfunc)(int mstatus)) { + return 0; +} + +INTERCEPTOR(int, mprobe, void *ptr) { + return 0; +} +#endif + static void InitializeCommonInterceptors() { static u64 metadata_mem[sizeof(MetadataHashMap) / sizeof(u64) + 1]; interceptor_metadata_map = new((void *)&metadata_mem) MetadataHashMap(); diff --git a/lib/sanitizer_common/sanitizer_common_interceptors_format.inc b/lib/sanitizer_common/sanitizer_common_interceptors_format.inc index 12563499c515..5ebe5a6ba0dd 100644 --- a/lib/sanitizer_common/sanitizer_common_interceptors_format.inc +++ b/lib/sanitizer_common/sanitizer_common_interceptors_format.inc @@ -325,8 +325,8 @@ static void scanf_common(void *ctx, int n_inputs, bool allowGnuMalloc, continue; int size = scanf_get_value_size(&dir); if (size == FSS_INVALID) { - Report("WARNING: unexpected format specifier in scanf interceptor: " - "%.*s\n", dir.end - dir.begin, dir.begin); + Report("%s: WARNING: unexpected format specifier in scanf interceptor: ", + SanitizerToolName, "%.*s\n", dir.end - dir.begin, dir.begin); break; } void *argp = va_arg(aq, void *); @@ -520,8 +520,12 @@ static void printf_common(void *ctx, const char *format, va_list aq) { continue; int size = printf_get_value_size(&dir); if (size == FSS_INVALID) { - Report("WARNING: unexpected format specifier in printf " - "interceptor: %.*s\n", dir.end - dir.begin, dir.begin); + static int ReportedOnce; + if (!ReportedOnce++) + Report( + "%s: WARNING: unexpected format specifier in printf " + "interceptor: %.*s (reported once per process)\n", + SanitizerToolName, dir.end - dir.begin, dir.begin); break; } if (dir.convSpecifier == 'n') { diff --git a/lib/sanitizer_common/sanitizer_platform_interceptors.h b/lib/sanitizer_common/sanitizer_platform_interceptors.h index a583e989c315..e5644ef25e83 100644 --- a/lib/sanitizer_common/sanitizer_platform_interceptors.h +++ b/lib/sanitizer_common/sanitizer_platform_interceptors.h @@ -339,5 +339,6 @@ #define SANITIZER_INTERCEPT_CFREE (!SI_FREEBSD && !SI_MAC) #define SANITIZER_INTERCEPT_ALIGNED_ALLOC (!SI_MAC) #define SANITIZER_INTERCEPT_MALLOC_USABLE_SIZE (!SI_MAC) +#define SANITIZER_INTERCEPT_MCHECK_MPROBE SI_LINUX_NOT_ANDROID #endif // #ifndef SANITIZER_PLATFORM_INTERCEPTORS_H diff --git a/lib/tsan/rtl/tsan_defs.h b/lib/tsan/rtl/tsan_defs.h index 8a0381e61ab0..8977fea7c552 100644 --- a/lib/tsan/rtl/tsan_defs.h +++ b/lib/tsan/rtl/tsan_defs.h @@ -157,6 +157,15 @@ struct MBlock { COMPILER_CHECK(sizeof(MBlock) == 16); +enum ExternalTag : uptr { + kExternalTagNone = 0, + kExternalTagSwiftModifyingAccess = 1, + kExternalTagFirstUserAvailable = 2, + kExternalTagMax = 1024, + // Don't set kExternalTagMax over 65,536, since MBlock only stores tags + // as 16-bit values, see tsan_defs.h. +}; + } // namespace __tsan #endif // TSAN_DEFS_H diff --git a/lib/tsan/rtl/tsan_external.cc b/lib/tsan/rtl/tsan_external.cc index 2d32b6dac75a..6c0e9477e41e 100644 --- a/lib/tsan/rtl/tsan_external.cc +++ b/lib/tsan/rtl/tsan_external.cc @@ -17,14 +17,30 @@ namespace __tsan { #define CALLERPC ((uptr)__builtin_return_address(0)) -const char *registered_tags[kExternalTagMax]; -static atomic_uint32_t used_tags{kExternalTagFirstUserAvailable}; // NOLINT. +struct TagData { + const char *object_type; + const char *header; +}; -const char *GetObjectTypeFromTag(uptr tag) { - if (tag == 0) return nullptr; +static TagData registered_tags[kExternalTagMax] = { + {}, + {"Swift variable", "Swift access race"}, +}; +static atomic_uint32_t used_tags{kExternalTagFirstUserAvailable}; // NOLINT. +static TagData *GetTagData(uptr tag) { // Invalid/corrupted tag? Better return NULL and let the caller deal with it. if (tag >= atomic_load(&used_tags, memory_order_relaxed)) return nullptr; - return registered_tags[tag]; + return ®istered_tags[tag]; +} + +const char *GetObjectTypeFromTag(uptr tag) { + TagData *tag_data = GetTagData(tag); + return tag_data ? tag_data->object_type : nullptr; +} + +const char *GetReportHeaderFromTag(uptr tag) { + TagData *tag_data = GetTagData(tag); + return tag_data ? tag_data->header : nullptr; } void InsertShadowStackFrameForTag(ThreadState *thr, uptr tag) { @@ -34,9 +50,9 @@ void InsertShadowStackFrameForTag(ThreadState *thr, uptr tag) { uptr TagFromShadowStackFrame(uptr pc) { uptr tag_count = atomic_load(&used_tags, memory_order_relaxed); void *pc_ptr = (void *)pc; - if (pc_ptr < ®istered_tags[0] || pc_ptr >= ®istered_tags[tag_count]) + if (pc_ptr < GetTagData(0) || pc_ptr > GetTagData(tag_count - 1)) return 0; - return (const char **)pc_ptr - ®istered_tags[0]; + return (TagData *)pc_ptr - GetTagData(0); } #if !SANITIZER_GO @@ -60,11 +76,26 @@ SANITIZER_INTERFACE_ATTRIBUTE void *__tsan_external_register_tag(const char *object_type) { uptr new_tag = atomic_fetch_add(&used_tags, 1, memory_order_relaxed); CHECK_LT(new_tag, kExternalTagMax); - registered_tags[new_tag] = internal_strdup(object_type); + GetTagData(new_tag)->object_type = internal_strdup(object_type); + char header[127] = {0}; + internal_snprintf(header, sizeof(header), "race on %s", object_type); + GetTagData(new_tag)->header = internal_strdup(header); return (void *)new_tag; } SANITIZER_INTERFACE_ATTRIBUTE +void __tsan_external_register_header(void *tag, const char *header) { + CHECK_GE((uptr)tag, kExternalTagFirstUserAvailable); + CHECK_LT((uptr)tag, kExternalTagMax); + atomic_uintptr_t *header_ptr = + (atomic_uintptr_t *)&GetTagData((uptr)tag)->header; + header = internal_strdup(header); + char *old_header = + (char *)atomic_exchange(header_ptr, (uptr)header, memory_order_seq_cst); + if (old_header) internal_free(old_header); +} + +SANITIZER_INTERFACE_ATTRIBUTE void __tsan_external_assign_tag(void *addr, void *tag) { CHECK_LT(tag, atomic_load(&used_tags, memory_order_relaxed)); Allocator *a = allocator(); diff --git a/lib/tsan/rtl/tsan_interface.h b/lib/tsan/rtl/tsan_interface.h index 71986283ee17..a80a48991cba 100644 --- a/lib/tsan/rtl/tsan_interface.h +++ b/lib/tsan/rtl/tsan_interface.h @@ -82,6 +82,8 @@ SANITIZER_INTERFACE_ATTRIBUTE void __tsan_ignore_thread_end(); SANITIZER_INTERFACE_ATTRIBUTE void *__tsan_external_register_tag(const char *object_type); SANITIZER_INTERFACE_ATTRIBUTE +void __tsan_external_register_header(void *tag, const char *header); +SANITIZER_INTERFACE_ATTRIBUTE void __tsan_external_assign_tag(void *addr, void *tag); SANITIZER_INTERFACE_ATTRIBUTE void __tsan_external_read(void *addr, void *caller_pc, void *tag); diff --git a/lib/tsan/rtl/tsan_report.cc b/lib/tsan/rtl/tsan_report.cc index b188af2a0d48..2de7ffc746fd 100644 --- a/lib/tsan/rtl/tsan_report.cc +++ b/lib/tsan/rtl/tsan_report.cc @@ -53,7 +53,8 @@ class Decorator: public __sanitizer::SanitizerCommonDecorator { }; ReportDesc::ReportDesc() - : stacks(MBlockReportStack) + : tag(kExternalTagNone) + , stacks(MBlockReportStack) , mops(MBlockReportMop) , locs(MBlockReportLoc) , mutexes(MBlockReportMutex) @@ -81,7 +82,7 @@ const char *thread_name(char *buf, int tid) { return buf; } -static const char *ReportTypeString(ReportType typ) { +static const char *ReportTypeString(ReportType typ, uptr tag) { if (typ == ReportTypeRace) return "data race"; if (typ == ReportTypeVptrRace) @@ -90,8 +91,9 @@ static const char *ReportTypeString(ReportType typ) { return "heap-use-after-free"; if (typ == ReportTypeVptrUseAfterFree) return "heap-use-after-free (virtual call vs free)"; - if (typ == ReportTypeExternalRace) - return "race on a library object"; + if (typ == ReportTypeExternalRace) { + return GetReportHeaderFromTag(tag) ?: "race on external object"; + } if (typ == ReportTypeThreadLeak) return "thread leak"; if (typ == ReportTypeMutexDestroyLocked) @@ -155,20 +157,21 @@ static const char *MopDesc(bool first, bool write, bool atomic) { } static const char *ExternalMopDesc(bool first, bool write) { - return first ? (write ? "Mutating" : "Read-only") - : (write ? "Previous mutating" : "Previous read-only"); + return first ? (write ? "Modifying" : "Read-only") + : (write ? "Previous modifying" : "Previous read-only"); } static void PrintMop(const ReportMop *mop, bool first) { Decorator d; char thrbuf[kThreadBufSize]; Printf("%s", d.Access()); - const char *object_type = GetObjectTypeFromTag(mop->external_tag); - if (mop->external_tag == kExternalTagNone || !object_type) { + if (mop->external_tag == kExternalTagNone) { Printf(" %s of size %d at %p by %s", MopDesc(first, mop->write, mop->atomic), mop->size, (void *)mop->addr, thread_name(thrbuf, mop->tid)); } else { + const char *object_type = + GetObjectTypeFromTag(mop->external_tag) ?: "external object"; Printf(" %s access of %s at %p by %s", ExternalMopDesc(first, mop->write), object_type, (void *)mop->addr, thread_name(thrbuf, mop->tid)); @@ -315,7 +318,7 @@ static SymbolizedStack *SkipTsanInternalFrames(SymbolizedStack *frames) { void PrintReport(const ReportDesc *rep) { Decorator d; Printf("==================\n"); - const char *rep_typ_str = ReportTypeString(rep->typ); + const char *rep_typ_str = ReportTypeString(rep->typ, rep->tag); Printf("%s", d.Warning()); Printf("WARNING: ThreadSanitizer: %s (pid=%d)\n", rep_typ_str, (int)internal_getpid()); diff --git a/lib/tsan/rtl/tsan_report.h b/lib/tsan/rtl/tsan_report.h index a0473e8dbdad..bc1582f90fe4 100644 --- a/lib/tsan/rtl/tsan_report.h +++ b/lib/tsan/rtl/tsan_report.h @@ -108,6 +108,7 @@ struct ReportMutex { class ReportDesc { public: ReportType typ; + uptr tag; Vector<ReportStack*> stacks; Vector<ReportMop*> mops; Vector<ReportLocation*> locs; diff --git a/lib/tsan/rtl/tsan_rtl.h b/lib/tsan/rtl/tsan_rtl.h index 8bf1c191ad76..e92a0f35705e 100644 --- a/lib/tsan/rtl/tsan_rtl.h +++ b/lib/tsan/rtl/tsan_rtl.h @@ -564,19 +564,13 @@ struct ScopedIgnoreInterceptors { } }; -enum ExternalTag : uptr { - kExternalTagNone = 0, - kExternalTagFirstUserAvailable = 1, - kExternalTagMax = 1024, - // Don't set kExternalTagMax over 65,536, since MBlock only stores tags - // as 16-bit values, see tsan_defs.h. -}; const char *GetObjectTypeFromTag(uptr tag); +const char *GetReportHeaderFromTag(uptr tag); uptr TagFromShadowStackFrame(uptr pc); class ScopedReport { public: - explicit ScopedReport(ReportType typ); + explicit ScopedReport(ReportType typ, uptr tag = kExternalTagNone); ~ScopedReport(); void AddMemoryAccess(uptr addr, uptr external_tag, Shadow s, StackTrace stack, diff --git a/lib/tsan/rtl/tsan_rtl_report.cc b/lib/tsan/rtl/tsan_rtl_report.cc index 055029b91f5b..68b9f50308ea 100644 --- a/lib/tsan/rtl/tsan_rtl_report.cc +++ b/lib/tsan/rtl/tsan_rtl_report.cc @@ -143,11 +143,12 @@ static ReportStack *SymbolizeStack(StackTrace trace) { return stack; } -ScopedReport::ScopedReport(ReportType typ) { +ScopedReport::ScopedReport(ReportType typ, uptr tag) { ctx->thread_registry->CheckLocked(); void *mem = internal_alloc(MBlockReport, sizeof(ReportDesc)); rep_ = new(mem) ReportDesc; rep_->typ = typ; + rep_->tag = tag; ctx->report_mtx.Lock(); CommonSanitizerReportMutex.Lock(); } @@ -651,12 +652,18 @@ void ReportRace(ThreadState *thr) { if (HandleRacyStacks(thr, traces, addr_min, addr_max)) return; - // If any of the two accesses has a tag, treat this as an "external" race. - if (tags[0] != kExternalTagNone || tags[1] != kExternalTagNone) - typ = ReportTypeExternalRace; + // If any of the accesses has a tag, treat this as an "external" race. + uptr tag = kExternalTagNone; + for (uptr i = 0; i < kMop; i++) { + if (tags[i] != kExternalTagNone) { + typ = ReportTypeExternalRace; + tag = tags[i]; + break; + } + } ThreadRegistryLock l0(ctx->thread_registry); - ScopedReport rep(typ); + ScopedReport rep(typ, tag); for (uptr i = 0; i < kMop; i++) { Shadow s(thr->racy_state[i]); rep.AddMemoryAccess(addr, tags[i], s, traces[i], diff --git a/test/asan/TestCases/Darwin/address-range-limit.mm b/test/asan/TestCases/Darwin/address-range-limit.mm index ba9175a2ce20..5f0fd89f8899 100644 --- a/test/asan/TestCases/Darwin/address-range-limit.mm +++ b/test/asan/TestCases/Darwin/address-range-limit.mm @@ -3,6 +3,9 @@ // RUN: %clangxx_asan %s -Wno-deprecated-declarations -flat_namespace -bundle -undefined suppress -o %t.bundle // RUN: %clangxx_asan %s -Wno-deprecated-declarations -o %t -framework Foundation && not %run %t 2>&1 | FileCheck %s +// NSCreateObjectFileImageFromFile/NSLinkModule isn't available on iOS +// UNSUPPORTED: ios + #import <Foundation/Foundation.h> #import <mach-o/dyld.h> diff --git a/test/asan/TestCases/Darwin/atos-symbolizer-dyld-root-path.cc b/test/asan/TestCases/Darwin/atos-symbolizer-dyld-root-path.cc index d2facd6d0c2e..fc3d0dd0b40d 100644 --- a/test/asan/TestCases/Darwin/atos-symbolizer-dyld-root-path.cc +++ b/test/asan/TestCases/Darwin/atos-symbolizer-dyld-root-path.cc @@ -6,6 +6,9 @@ // Due to a bug in atos, this only works on x86_64. // REQUIRES: asan-64-bits +// Path returned by `which atos` is invalid on iOS. +// UNSUPPORTED: ios + #include <stdlib.h> #include <string.h> int main(int argc, char **argv) { diff --git a/test/asan/TestCases/Darwin/atos-symbolizer.cc b/test/asan/TestCases/Darwin/atos-symbolizer.cc index b4a868e242ea..7b091c4d681c 100644 --- a/test/asan/TestCases/Darwin/atos-symbolizer.cc +++ b/test/asan/TestCases/Darwin/atos-symbolizer.cc @@ -3,6 +3,9 @@ // RUN: %clangxx_asan -O0 %s -o %t // RUN: %env_asan_opts=verbosity=2 ASAN_SYMBOLIZER_PATH=$(which atos) not %run %t 2>&1 | FileCheck %s +// Path returned by `which atos` is invalid on iOS. +// UNSUPPORTED: ios + #include <stdlib.h> #include <string.h> int main(int argc, char **argv) { diff --git a/test/asan/TestCases/Darwin/dladdr-demangling.cc b/test/asan/TestCases/Darwin/dladdr-demangling.cc index 6f52b93da04b..fb6f6d79b5f4 100644 --- a/test/asan/TestCases/Darwin/dladdr-demangling.cc +++ b/test/asan/TestCases/Darwin/dladdr-demangling.cc @@ -5,6 +5,9 @@ // RUN: not %run %t 2>&1 | FileCheck %s // RUN: %env_asan_opts=verbosity=2 not %run sandbox-exec -p '(version 1)(allow default)(deny process-fork)' %t 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-DLADDR +// sandbox-exec isn't available on iOS +// UNSUPPORTED: ios + #include <stdlib.h> class MyClass { diff --git a/test/asan/TestCases/Darwin/dyld_insert_libraries_reexec.cc b/test/asan/TestCases/Darwin/dyld_insert_libraries_reexec.cc index b22036a7efed..5c975b8dad2b 100644 --- a/test/asan/TestCases/Darwin/dyld_insert_libraries_reexec.cc +++ b/test/asan/TestCases/Darwin/dyld_insert_libraries_reexec.cc @@ -1,6 +1,8 @@ // When DYLD-inserting the ASan dylib from a different location than the // original, make sure we don't try to reexec. +// UNSUPPORTED: ios + // RUN: mkdir -p %T/dyld_insert_libraries_reexec // RUN: cp `%clang_asan %s -fsanitize=address -### 2>&1 \ // RUN: | grep "libclang_rt.asan_osx_dynamic.dylib" \ diff --git a/test/asan/TestCases/Darwin/dyld_insert_libraries_remove.cc b/test/asan/TestCases/Darwin/dyld_insert_libraries_remove.cc index a3af8c156ef2..69d849793d7a 100644 --- a/test/asan/TestCases/Darwin/dyld_insert_libraries_remove.cc +++ b/test/asan/TestCases/Darwin/dyld_insert_libraries_remove.cc @@ -2,6 +2,8 @@ // the ASan dylib from the environment variable (both when using an absolute // or relative path) and also that the other dylibs are left untouched. +// UNSUPPORTED: ios + // RUN: mkdir -p %T/dyld_insert_libraries_remove // RUN: cp `%clang_asan %s -fsanitize=address -### 2>&1 \ // RUN: | grep "libclang_rt.asan_osx_dynamic.dylib" \ diff --git a/test/asan/TestCases/Darwin/haswell-symbolication.cc b/test/asan/TestCases/Darwin/haswell-symbolication.cc index 59c938ca5087..7856c4d61e16 100644 --- a/test/asan/TestCases/Darwin/haswell-symbolication.cc +++ b/test/asan/TestCases/Darwin/haswell-symbolication.cc @@ -48,6 +48,7 @@ // REQUIRES: x86-target-arch // REQUIRES: x86_64h +// UNSUPPORTED: ios #include <sanitizer/common_interface_defs.h> #include <stdio.h> diff --git a/test/asan/TestCases/Darwin/interface_symbols_darwin.c b/test/asan/TestCases/Darwin/interface_symbols_darwin.c index 9450575b4ecd..09af1ece589f 100644 --- a/test/asan/TestCases/Darwin/interface_symbols_darwin.c +++ b/test/asan/TestCases/Darwin/interface_symbols_darwin.c @@ -31,4 +31,6 @@ // RUN: echo "=== NOTE === If you see a mismatch below, please update sanitizer_interface.inc files." // RUN: diff %t.imports-sorted %t.exports-sorted +// UNSUPPORTED: ios + int main() { return 0; } diff --git a/test/asan/TestCases/Darwin/sandbox-symbolizer.cc b/test/asan/TestCases/Darwin/sandbox-symbolizer.cc index 4310f9c599e3..b36c4faedd55 100644 --- a/test/asan/TestCases/Darwin/sandbox-symbolizer.cc +++ b/test/asan/TestCases/Darwin/sandbox-symbolizer.cc @@ -12,6 +12,9 @@ // RUN: not %run sandbox-exec -p '(version 1)(allow default)(deny mach-priv-task-port)' %t 2>&1 | FileCheck %s // RUN: env ASAN_SYMBOLIZER_PATH="" not %run sandbox-exec -p '(version 1)(allow default)(deny mach-priv-task-port)' %t 2>&1 | FileCheck %s +// sandbox-exec isn't available on iOS +// UNSUPPORTED: ios + #include <stdlib.h> int main() { char *x = (char*)malloc(10 * sizeof(char)); diff --git a/test/asan/TestCases/Darwin/suppressions-sandbox.cc b/test/asan/TestCases/Darwin/suppressions-sandbox.cc index c0b84addaa81..966f21346e4f 100644 --- a/test/asan/TestCases/Darwin/suppressions-sandbox.cc +++ b/test/asan/TestCases/Darwin/suppressions-sandbox.cc @@ -8,6 +8,9 @@ // RUN: sandbox-exec -p '(version 1)(allow default)(deny process-fork)' \ // RUN: %run %t 2>&1 | FileCheck --check-prefix=CHECK-IGNORE %s +// sandbox-exec isn't available on iOS +// UNSUPPORTED: ios + #include <CoreFoundation/CoreFoundation.h> int main() { diff --git a/test/asan/TestCases/Darwin/uuid.cc b/test/asan/TestCases/Darwin/uuid.cc index 3f50272e901d..33638587e129 100644 --- a/test/asan/TestCases/Darwin/uuid.cc +++ b/test/asan/TestCases/Darwin/uuid.cc @@ -4,6 +4,9 @@ // RUN: %clangxx_asan %s -o %t -fsanitize-recover=address // RUN: %env_asan_opts=print_module_map=2:halt_on_error=0 %run %t 2>&1 | FileCheck %s +// We can't run system("otool") in the simulator. +// UNSUPPORTED: ios + #include <stdio.h> #include <stdlib.h> #include <string.h> diff --git a/test/asan/TestCases/Posix/closed-fds.cc b/test/asan/TestCases/Posix/closed-fds.cc index 75e3216aab5a..b2604bba58ba 100644 --- a/test/asan/TestCases/Posix/closed-fds.cc +++ b/test/asan/TestCases/Posix/closed-fds.cc @@ -8,6 +8,7 @@ // FIXME: copy %t.log back from the device and re-enable on Android. // UNSUPPORTED: android +// UNSUPPORTED: ios #include <assert.h> #include <stdio.h> diff --git a/test/asan/TestCases/Posix/coverage-maybe-open-file.cc b/test/asan/TestCases/Posix/coverage-maybe-open-file.cc index 95f2b5449e83..ee2977af11c4 100644 --- a/test/asan/TestCases/Posix/coverage-maybe-open-file.cc +++ b/test/asan/TestCases/Posix/coverage-maybe-open-file.cc @@ -1,5 +1,6 @@ // FIXME: https://code.google.com/p/address-sanitizer/issues/detail?id=316 // XFAIL: android +// UNSUPPORTED: ios // // RUN: %clangxx_asan -fsanitize-coverage=func %s -o %t // RUN: rm -rf %T/coverage-maybe-open-file diff --git a/test/asan/TestCases/Posix/coverage-module-unloaded.cc b/test/asan/TestCases/Posix/coverage-module-unloaded.cc index d492af6662fa..db27283a62c6 100644 --- a/test/asan/TestCases/Posix/coverage-module-unloaded.cc +++ b/test/asan/TestCases/Posix/coverage-module-unloaded.cc @@ -10,6 +10,7 @@ // // https://code.google.com/p/address-sanitizer/issues/detail?id=263 // XFAIL: android +// UNSUPPORTED: ios #include <assert.h> #include <dlfcn.h> diff --git a/test/asan/TestCases/Posix/coverage-sandboxing.cc b/test/asan/TestCases/Posix/coverage-sandboxing.cc index 431dce149525..354070708a7d 100644 --- a/test/asan/TestCases/Posix/coverage-sandboxing.cc +++ b/test/asan/TestCases/Posix/coverage-sandboxing.cc @@ -21,6 +21,7 @@ // https://code.google.com/p/address-sanitizer/issues/detail?id=263 // XFAIL: android +// UNSUPPORTED: ios #include <assert.h> #include <fcntl.h> diff --git a/test/asan/TestCases/Posix/coverage.cc b/test/asan/TestCases/Posix/coverage.cc index 3d1dccfbd549..bff060968483 100644 --- a/test/asan/TestCases/Posix/coverage.cc +++ b/test/asan/TestCases/Posix/coverage.cc @@ -18,6 +18,7 @@ // // https://code.google.com/p/address-sanitizer/issues/detail?id=263 // XFAIL: android +// UNSUPPORTED: ios #include <sanitizer/coverage_interface.h> #include <assert.h> diff --git a/test/asan/TestCases/Posix/glob.cc b/test/asan/TestCases/Posix/glob.cc index e0eeb33cca24..46d4a0d8d43d 100644 --- a/test/asan/TestCases/Posix/glob.cc +++ b/test/asan/TestCases/Posix/glob.cc @@ -1,5 +1,6 @@ // FIXME: https://code.google.com/p/address-sanitizer/issues/detail?id=316 // XFAIL: android +// UNSUPPORTED: ios // // RUN: %clangxx_asan -O0 %s -o %t && %run %t %p 2>&1 | FileCheck %s // RUN: %clangxx_asan -O3 %s -o %t && %run %t %p 2>&1 | FileCheck %s diff --git a/test/asan/TestCases/Posix/start-deactivated.cc b/test/asan/TestCases/Posix/start-deactivated.cc index 2a2aa674c04c..2870ffb2f454 100644 --- a/test/asan/TestCases/Posix/start-deactivated.cc +++ b/test/asan/TestCases/Posix/start-deactivated.cc @@ -19,6 +19,7 @@ // RUN: ASAN_ACTIVATION_OPTIONS=help=1,handle_segv=0,verbosity=1 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-UNSUPPORTED // XFAIL: arm-linux-gnueabi +// UNSUPPORTED: ios // END. diff --git a/test/asan/TestCases/Windows/coverage-dll-stdio.cc b/test/asan/TestCases/Windows/coverage-dll-stdio.cc index 5e12e3855449..92cd0a7bc043 100644 --- a/test/asan/TestCases/Windows/coverage-dll-stdio.cc +++ b/test/asan/TestCases/Windows/coverage-dll-stdio.cc @@ -2,8 +2,8 @@ // __local_stdio_printf_options function isn't instrumented for coverage. // RUN: rm -rf %t && mkdir %t && cd %t -// RUN: %clang_cl_asan -fsanitize-coverage=func -O0 %p/dll_host.cc -Fet.exe -// RUN: %clang_cl_asan -fsanitize-coverage=func -LD -O0 %s -Fet.dll +// RUN: %clang_cl_asan -fsanitize-coverage=func,trace-pc-guard -O0 %p/dll_host.cc -Fet.exe +// RUN: %clang_cl_asan -fsanitize-coverage=func,trace-pc-guard -LD -O0 %s -Fet.dll // RUN: %run ./t.exe t.dll 2>&1 | FileCheck %s #include <stdio.h> diff --git a/test/asan/TestCases/default_blacklist.cc b/test/asan/TestCases/default_blacklist.cc index 9358cc47cbaa..84c0438f3058 100644 --- a/test/asan/TestCases/default_blacklist.cc +++ b/test/asan/TestCases/default_blacklist.cc @@ -1,5 +1,6 @@ // FIXME: https://code.google.com/p/address-sanitizer/issues/detail?id=316 // XFAIL: android +// UNSUPPORTED: ios // // Test that ASan uses the default blacklist from resource directory. // RUN: %clangxx_asan -### %s 2>&1 | FileCheck %s diff --git a/test/asan/TestCases/log-path_test.cc b/test/asan/TestCases/log-path_test.cc index b4218ad85230..710d22017700 100644 --- a/test/asan/TestCases/log-path_test.cc +++ b/test/asan/TestCases/log-path_test.cc @@ -1,5 +1,6 @@ // FIXME: https://code.google.com/p/address-sanitizer/issues/detail?id=316 // XFAIL: android +// UNSUPPORTED: ios // // The for loop in the backticks below requires bash. // REQUIRES: shell diff --git a/test/asan/TestCases/suppressions-exec-relative-location.cc b/test/asan/TestCases/suppressions-exec-relative-location.cc index 740cecee15c0..d4e214d35a0e 100644 --- a/test/asan/TestCases/suppressions-exec-relative-location.cc +++ b/test/asan/TestCases/suppressions-exec-relative-location.cc @@ -25,6 +25,7 @@ // XFAIL: android // XFAIL: win32 +// UNSUPPORTED: ios #include <stdio.h> #include <stdlib.h> diff --git a/test/asan/TestCases/suppressions-function.cc b/test/asan/TestCases/suppressions-function.cc index d5ac9f7792ba..c7f1ebe66968 100644 --- a/test/asan/TestCases/suppressions-function.cc +++ b/test/asan/TestCases/suppressions-function.cc @@ -8,6 +8,7 @@ // FIXME: Windows symbolizer needs work to make this pass. // XFAIL: android,win32 +// UNSUPPORTED: ios #include <stdio.h> #include <stdlib.h> diff --git a/test/asan/TestCases/verbose-log-path_test.cc b/test/asan/TestCases/verbose-log-path_test.cc index 47a5c226a1bf..a63c58475242 100644 --- a/test/asan/TestCases/verbose-log-path_test.cc +++ b/test/asan/TestCases/verbose-log-path_test.cc @@ -10,6 +10,7 @@ // FIXME: only FreeBSD and Linux have verbose log paths now. // XFAIL: win32,android +// UNSUPPORTED: ios #include <stdlib.h> #include <string.h> diff --git a/test/sanitizer_common/TestCases/Linux/mprobe.cc b/test/sanitizer_common/TestCases/Linux/mprobe.cc new file mode 100644 index 000000000000..57e5ba5a6c74 --- /dev/null +++ b/test/sanitizer_common/TestCases/Linux/mprobe.cc @@ -0,0 +1,42 @@ +// RUN: %clangxx %s -o %t && %run %t 2>&1 | FileCheck %s +// UNSUPPORTED: android + +#include <stdio.h> +#include <stdlib.h> +#if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 2) +#include <mcheck.h> +#else +#define MCHECK_OK 0 +extern "C" int mcheck(void (*abortfunc)(int mstatus)); +extern "C" int mcheck_pedantic(void (*abortfunc)(int mstatus)); +extern "C" int mprobe(void *ptr); +#endif + +void check_heap() { + void *p = malloc(1000); + int res = mprobe(p); + if (res == MCHECK_OK) + printf("Success!\n"); + free(p); +} + +int main(int argc, char *argv[]) { + void *p; + if (mcheck(NULL) != 0) { + fprintf(stderr, "mcheck() failed\n"); + exit(EXIT_FAILURE); + } + + check_heap(); + // CHECK: Success! + + if (mcheck_pedantic(NULL) != 0) { + fprintf(stderr, "mcheck_pedantic() failed\n"); + exit(EXIT_FAILURE); + } + + check_heap(); + // CHECK: Success! + + return 0; +} diff --git a/test/sanitizer_common/TestCases/Linux/unexpected_format_specifier_test.cc b/test/sanitizer_common/TestCases/Linux/unexpected_format_specifier_test.cc new file mode 100644 index 000000000000..f48cce8ea22b --- /dev/null +++ b/test/sanitizer_common/TestCases/Linux/unexpected_format_specifier_test.cc @@ -0,0 +1,12 @@ +// RUN: %clang -w -O0 %s -o %t && %run %t 2>&1 | FileCheck %s +// UNSUPPORTED: lsan +// UNSUPPORTED: msan +#include <stdio.h> +int main() { + int a; + printf("%Q\n", 1); + printf("%Q\n", 1); + printf("%Q\n", 1); +} +// CHECK: unexpected format specifier in printf interceptor: %Q (reported once per process) +// CHECK-NOT: unexpected format specifier in printf interceptor diff --git a/test/tsan/Darwin/external-dups.cc b/test/tsan/Darwin/external-dups.cc index 79432bac4a02..ca1eb3e7cc43 100644 --- a/test/tsan/Darwin/external-dups.cc +++ b/test/tsan/Darwin/external-dups.cc @@ -28,7 +28,7 @@ int main(int argc, char *argv[]) { barrier_wait(&barrier); ExternalWrite(opaque_object); }); - // CHECK: WARNING: ThreadSanitizer: race on a library object + // CHECK: WARNING: ThreadSanitizer: race on HelloWorld t1.join(); t2.join(); } @@ -46,7 +46,7 @@ int main(int argc, char *argv[]) { barrier_wait(&barrier); ExternalWrite(opaque_object); }); - // CHECK: WARNING: ThreadSanitizer: race on a library object + // CHECK: WARNING: ThreadSanitizer: race on HelloWorld t1.join(); t2.join(); } diff --git a/test/tsan/Darwin/external-swift.cc b/test/tsan/Darwin/external-swift.cc new file mode 100644 index 000000000000..f6f9e7f4ece3 --- /dev/null +++ b/test/tsan/Darwin/external-swift.cc @@ -0,0 +1,92 @@ +// RUN: %clangxx_tsan %s -o %t +// RUN: %deflake %run %t 2>&1 | FileCheck %s + +#include <thread> + +#import "../test.h" + +extern "C" { +void __tsan_write8(void *addr); +} + +static void *tag = (void *)0x1; + +__attribute__((no_sanitize("thread"))) +void ExternalWrite(void *addr) { + __tsan_external_write(addr, nullptr, tag); +} + +__attribute__((no_sanitize("thread"))) +void RegularWrite(void *addr) { + __tsan_write8(addr); +} + +int main(int argc, char *argv[]) { + barrier_init(&barrier, 2); + fprintf(stderr, "Start.\n"); + // CHECK: Start. + + { + void *opaque_object = malloc(16); + std::thread t1([opaque_object] { + ExternalWrite(opaque_object); + barrier_wait(&barrier); + }); + std::thread t2([opaque_object] { + barrier_wait(&barrier); + ExternalWrite(opaque_object); + }); + // CHECK: WARNING: ThreadSanitizer: Swift access race + // CHECK: Modifying access of Swift variable at {{.*}} by thread {{.*}} + // CHECK: Previous modifying access of Swift variable at {{.*}} by thread {{.*}} + // CHECK: SUMMARY: ThreadSanitizer: Swift access race + t1.join(); + t2.join(); + } + + fprintf(stderr, "external+external test done.\n"); + // CHECK: external+external test done. + + { + void *opaque_object = malloc(16); + std::thread t1([opaque_object] { + ExternalWrite(opaque_object); + barrier_wait(&barrier); + }); + std::thread t2([opaque_object] { + barrier_wait(&barrier); + RegularWrite(opaque_object); + }); + // CHECK: WARNING: ThreadSanitizer: Swift access race + // CHECK: Write of size 8 at {{.*}} by thread {{.*}} + // CHECK: Previous modifying access of Swift variable at {{.*}} by thread {{.*}} + // CHECK: SUMMARY: ThreadSanitizer: Swift access race + t1.join(); + t2.join(); + } + + fprintf(stderr, "external+regular test done.\n"); + // CHECK: external+regular test done. + + { + void *opaque_object = malloc(16); + std::thread t1([opaque_object] { + RegularWrite(opaque_object); + barrier_wait(&barrier); + }); + std::thread t2([opaque_object] { + barrier_wait(&barrier); + ExternalWrite(opaque_object); + }); + // CHECK: WARNING: ThreadSanitizer: Swift access race + // CHECK: Modifying access of Swift variable at {{.*}} by thread {{.*}} + // CHECK: Previous write of size 8 at {{.*}} by thread {{.*}} + // CHECK: SUMMARY: ThreadSanitizer: Swift access race + t1.join(); + t2.join(); + } + + fprintf(stderr, "regular+external test done.\n"); + // CHECK: regular+external test done. +} + diff --git a/test/tsan/Darwin/external.cc b/test/tsan/Darwin/external.cc index 211694ab7db1..e72281afa488 100644 --- a/test/tsan/Darwin/external.cc +++ b/test/tsan/Darwin/external.cc @@ -67,13 +67,14 @@ int main(int argc, char *argv[]) { // TEST2-NOT: WARNING: ThreadSanitizer - // TEST3: WARNING: ThreadSanitizer: race on a library object - // TEST3: {{Mutating|read-only}} access of MyLibrary::MyObject at + // TEST3: WARNING: ThreadSanitizer: race on MyLibrary::MyObject + // TEST3: {{Modifying|read-only}} access of MyLibrary::MyObject at // TEST3: {{ObjectWrite|ObjectRead}} - // TEST3: Previous {{mutating|read-only}} access of MyLibrary::MyObject at + // TEST3: Previous {{modifying|read-only}} access of MyLibrary::MyObject at // TEST3: {{ObjectWrite|ObjectRead}} // TEST3: Location is MyLibrary::MyObject of size 16 at // TEST3: {{ObjectCreate}} + // TEST3: SUMMARY: ThreadSanitizer: race on MyLibrary::MyObject {{.*}} in {{ObjectWrite|ObjectRead}} fprintf(stderr, "RW test done\n"); // CHECK: RW test done @@ -90,13 +91,14 @@ int main(int argc, char *argv[]) { // TEST2-NOT: WARNING: ThreadSanitizer - // TEST3: WARNING: ThreadSanitizer: race on a library object - // TEST3: Mutating access of MyLibrary::MyObject at + // TEST3: WARNING: ThreadSanitizer: race on MyLibrary::MyObject + // TEST3: Modifying access of MyLibrary::MyObject at // TEST3: {{ObjectWrite|ObjectWriteAnother}} - // TEST3: Previous mutating access of MyLibrary::MyObject at + // TEST3: Previous modifying access of MyLibrary::MyObject at // TEST3: {{ObjectWrite|ObjectWriteAnother}} // TEST3: Location is MyLibrary::MyObject of size 16 at // TEST3: {{ObjectCreate}} + // TEST3: SUMMARY: ThreadSanitizer: race on MyLibrary::MyObject {{.*}} in {{ObjectWrite|ObjectWriteAnother}} fprintf(stderr, "WW test done\n"); // CHECK: WW test done |