2019-08-14 10:47:11 +02:00
|
|
|
//===-- tsan_interface_ann.cpp --------------------------------------------===//
|
2012-11-22 23:03:11 +01:00
|
|
|
//
|
2019-08-14 10:47:11 +02:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2012-11-22 23:03:11 +01:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file is a part of ThreadSanitizer (TSan), a race detector.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "sanitizer_common/sanitizer_libc.h"
|
2012-12-05 14:19:55 +01:00
|
|
|
#include "sanitizer_common/sanitizer_internal_defs.h"
|
2012-11-22 23:03:11 +01:00
|
|
|
#include "sanitizer_common/sanitizer_placement_new.h"
|
2013-11-04 22:33:31 +01:00
|
|
|
#include "sanitizer_common/sanitizer_stacktrace.h"
|
2018-10-31 12:14:23 +01:00
|
|
|
#include "sanitizer_common/sanitizer_vector.h"
|
2012-11-22 23:03:11 +01:00
|
|
|
#include "tsan_interface_ann.h"
|
|
|
|
#include "tsan_mutex.h"
|
|
|
|
#include "tsan_report.h"
|
|
|
|
#include "tsan_rtl.h"
|
|
|
|
#include "tsan_mman.h"
|
|
|
|
#include "tsan_flags.h"
|
|
|
|
#include "tsan_platform.h"
|
|
|
|
|
|
|
|
#define CALLERPC ((uptr)__builtin_return_address(0))
|
|
|
|
|
2019-11-05 14:54:57 +01:00
|
|
|
using namespace __tsan;
|
2012-11-22 23:03:11 +01:00
|
|
|
|
|
|
|
namespace __tsan {
|
|
|
|
|
|
|
|
class ScopedAnnotation {
|
|
|
|
public:
|
ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins...
* ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch
builtins, store max (log2 (align), 0) into uchar field instead of
align into uptr field.
(ubsan_expand_objsize_ifn): Use _v1 suffixed type mismatch builtins,
store uchar 0 field instead of uptr 0 field.
(instrument_nonnull_return): Use _v1 suffixed nonnull return builtin,
instead of passing one address of struct with 2 locations pass
two addresses of structs with 1 location each.
* sanitizer.def (BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH,
BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH_ABORT,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_ABORT): Removed.
(BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH_V1,
BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH_V1_ABORT,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_V1,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_V1_ABORT): New builtins.
* c-c++-common/ubsan/float-cast-overflow-1.c: Drop value keyword
from expected output regexps.
* c-c++-common/ubsan/float-cast-overflow-2.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-3.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-4.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-5.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-6.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-8.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-9.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-10.c: Likewise.
* g++.dg/ubsan/float-cast-overflow-bf.C: Likewise.
* gcc.dg/ubsan/float-cast-overflow-bf.c: Likewise.
* g++.dg/asan/default-options-1.C (__asan_default_options): Add
used attribute.
* g++.dg/asan/asan_test.C: Run with ASAN_OPTIONS=handle_segv=2
in the environment.
* All source files: Merge from upstream 315899.
* asan/Makefile.am (nodist_saninclude_HEADERS): Add
include/sanitizer/tsan_interface.h.
* asan/libtool-version: Bump the libasan SONAME.
* lsan/Makefile.am (sanitizer_lsan_files): Add lsan_common_mac.cc.
(lsan_files): Add lsan_linux.cc, lsan_mac.cc and lsan_malloc_mac.cc.
* sanitizer_common/Makefile.am (sanitizer_common_files): Add
sancov_flags.cc, sanitizer_allocator_checks.cc,
sanitizer_coverage_libcdep_new.cc, sanitizer_errno.cc,
sanitizer_file.cc, sanitizer_mac_libcdep.cc and
sanitizer_stoptheworld_mac.cc. Remove sanitizer_coverage_libcdep.cc
and sanitizer_coverage_mapping_libcdep.cc.
* tsan/Makefile.am (tsan_files): Add tsan_external.cc.
* ubsan/Makefile.am (DEFS): Add -DUBSAN_CAN_USE_CXXABI=1.
(ubsan_files): Add ubsan_init_standalone.cc and
ubsan_signals_standalone.cc.
* ubsan/libtool-version: Bump the libubsan SONAME.
* asan/Makefile.in: Regenerate.
* lsan/Makefile.in: Regenerate.
* sanitizer_common/Makefile.in: Regenerate.
* tsan/Makefile.in: Regenerate.
* ubsan/Makefile.in: Regenerate.
From-SVN: r253887
2017-10-19 13:23:59 +02:00
|
|
|
ScopedAnnotation(ThreadState *thr, const char *aname, uptr pc)
|
2014-05-22 09:09:21 +02:00
|
|
|
: thr_(thr) {
|
2012-11-22 23:03:11 +01:00
|
|
|
FuncEntry(thr_, pc);
|
ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins...
* ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch
builtins, store max (log2 (align), 0) into uchar field instead of
align into uptr field.
(ubsan_expand_objsize_ifn): Use _v1 suffixed type mismatch builtins,
store uchar 0 field instead of uptr 0 field.
(instrument_nonnull_return): Use _v1 suffixed nonnull return builtin,
instead of passing one address of struct with 2 locations pass
two addresses of structs with 1 location each.
* sanitizer.def (BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH,
BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH_ABORT,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_ABORT): Removed.
(BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH_V1,
BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH_V1_ABORT,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_V1,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_V1_ABORT): New builtins.
* c-c++-common/ubsan/float-cast-overflow-1.c: Drop value keyword
from expected output regexps.
* c-c++-common/ubsan/float-cast-overflow-2.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-3.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-4.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-5.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-6.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-8.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-9.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-10.c: Likewise.
* g++.dg/ubsan/float-cast-overflow-bf.C: Likewise.
* gcc.dg/ubsan/float-cast-overflow-bf.c: Likewise.
* g++.dg/asan/default-options-1.C (__asan_default_options): Add
used attribute.
* g++.dg/asan/asan_test.C: Run with ASAN_OPTIONS=handle_segv=2
in the environment.
* All source files: Merge from upstream 315899.
* asan/Makefile.am (nodist_saninclude_HEADERS): Add
include/sanitizer/tsan_interface.h.
* asan/libtool-version: Bump the libasan SONAME.
* lsan/Makefile.am (sanitizer_lsan_files): Add lsan_common_mac.cc.
(lsan_files): Add lsan_linux.cc, lsan_mac.cc and lsan_malloc_mac.cc.
* sanitizer_common/Makefile.am (sanitizer_common_files): Add
sancov_flags.cc, sanitizer_allocator_checks.cc,
sanitizer_coverage_libcdep_new.cc, sanitizer_errno.cc,
sanitizer_file.cc, sanitizer_mac_libcdep.cc and
sanitizer_stoptheworld_mac.cc. Remove sanitizer_coverage_libcdep.cc
and sanitizer_coverage_mapping_libcdep.cc.
* tsan/Makefile.am (tsan_files): Add tsan_external.cc.
* ubsan/Makefile.am (DEFS): Add -DUBSAN_CAN_USE_CXXABI=1.
(ubsan_files): Add ubsan_init_standalone.cc and
ubsan_signals_standalone.cc.
* ubsan/libtool-version: Bump the libubsan SONAME.
* asan/Makefile.in: Regenerate.
* lsan/Makefile.in: Regenerate.
* sanitizer_common/Makefile.in: Regenerate.
* tsan/Makefile.in: Regenerate.
* ubsan/Makefile.in: Regenerate.
From-SVN: r253887
2017-10-19 13:23:59 +02:00
|
|
|
DPrintf("#%d: annotation %s()\n", thr_->tid, aname);
|
2012-11-22 23:03:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
~ScopedAnnotation() {
|
|
|
|
FuncExit(thr_);
|
2014-09-23 19:59:53 +02:00
|
|
|
CheckNoLocks(thr_);
|
2012-11-22 23:03:11 +01:00
|
|
|
}
|
|
|
|
private:
|
|
|
|
ThreadState *const thr_;
|
|
|
|
};
|
|
|
|
|
ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins...
* ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch
builtins, store max (log2 (align), 0) into uchar field instead of
align into uptr field.
(ubsan_expand_objsize_ifn): Use _v1 suffixed type mismatch builtins,
store uchar 0 field instead of uptr 0 field.
(instrument_nonnull_return): Use _v1 suffixed nonnull return builtin,
instead of passing one address of struct with 2 locations pass
two addresses of structs with 1 location each.
* sanitizer.def (BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH,
BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH_ABORT,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_ABORT): Removed.
(BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH_V1,
BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH_V1_ABORT,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_V1,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_V1_ABORT): New builtins.
* c-c++-common/ubsan/float-cast-overflow-1.c: Drop value keyword
from expected output regexps.
* c-c++-common/ubsan/float-cast-overflow-2.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-3.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-4.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-5.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-6.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-8.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-9.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-10.c: Likewise.
* g++.dg/ubsan/float-cast-overflow-bf.C: Likewise.
* gcc.dg/ubsan/float-cast-overflow-bf.c: Likewise.
* g++.dg/asan/default-options-1.C (__asan_default_options): Add
used attribute.
* g++.dg/asan/asan_test.C: Run with ASAN_OPTIONS=handle_segv=2
in the environment.
* All source files: Merge from upstream 315899.
* asan/Makefile.am (nodist_saninclude_HEADERS): Add
include/sanitizer/tsan_interface.h.
* asan/libtool-version: Bump the libasan SONAME.
* lsan/Makefile.am (sanitizer_lsan_files): Add lsan_common_mac.cc.
(lsan_files): Add lsan_linux.cc, lsan_mac.cc and lsan_malloc_mac.cc.
* sanitizer_common/Makefile.am (sanitizer_common_files): Add
sancov_flags.cc, sanitizer_allocator_checks.cc,
sanitizer_coverage_libcdep_new.cc, sanitizer_errno.cc,
sanitizer_file.cc, sanitizer_mac_libcdep.cc and
sanitizer_stoptheworld_mac.cc. Remove sanitizer_coverage_libcdep.cc
and sanitizer_coverage_mapping_libcdep.cc.
* tsan/Makefile.am (tsan_files): Add tsan_external.cc.
* ubsan/Makefile.am (DEFS): Add -DUBSAN_CAN_USE_CXXABI=1.
(ubsan_files): Add ubsan_init_standalone.cc and
ubsan_signals_standalone.cc.
* ubsan/libtool-version: Bump the libubsan SONAME.
* asan/Makefile.in: Regenerate.
* lsan/Makefile.in: Regenerate.
* sanitizer_common/Makefile.in: Regenerate.
* tsan/Makefile.in: Regenerate.
* ubsan/Makefile.in: Regenerate.
From-SVN: r253887
2017-10-19 13:23:59 +02:00
|
|
|
#define SCOPED_ANNOTATION_RET(typ, ret) \
|
2012-11-22 23:03:11 +01:00
|
|
|
if (!flags()->enable_annotations) \
|
ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins...
* ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch
builtins, store max (log2 (align), 0) into uchar field instead of
align into uptr field.
(ubsan_expand_objsize_ifn): Use _v1 suffixed type mismatch builtins,
store uchar 0 field instead of uptr 0 field.
(instrument_nonnull_return): Use _v1 suffixed nonnull return builtin,
instead of passing one address of struct with 2 locations pass
two addresses of structs with 1 location each.
* sanitizer.def (BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH,
BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH_ABORT,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_ABORT): Removed.
(BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH_V1,
BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH_V1_ABORT,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_V1,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_V1_ABORT): New builtins.
* c-c++-common/ubsan/float-cast-overflow-1.c: Drop value keyword
from expected output regexps.
* c-c++-common/ubsan/float-cast-overflow-2.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-3.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-4.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-5.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-6.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-8.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-9.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-10.c: Likewise.
* g++.dg/ubsan/float-cast-overflow-bf.C: Likewise.
* gcc.dg/ubsan/float-cast-overflow-bf.c: Likewise.
* g++.dg/asan/default-options-1.C (__asan_default_options): Add
used attribute.
* g++.dg/asan/asan_test.C: Run with ASAN_OPTIONS=handle_segv=2
in the environment.
* All source files: Merge from upstream 315899.
* asan/Makefile.am (nodist_saninclude_HEADERS): Add
include/sanitizer/tsan_interface.h.
* asan/libtool-version: Bump the libasan SONAME.
* lsan/Makefile.am (sanitizer_lsan_files): Add lsan_common_mac.cc.
(lsan_files): Add lsan_linux.cc, lsan_mac.cc and lsan_malloc_mac.cc.
* sanitizer_common/Makefile.am (sanitizer_common_files): Add
sancov_flags.cc, sanitizer_allocator_checks.cc,
sanitizer_coverage_libcdep_new.cc, sanitizer_errno.cc,
sanitizer_file.cc, sanitizer_mac_libcdep.cc and
sanitizer_stoptheworld_mac.cc. Remove sanitizer_coverage_libcdep.cc
and sanitizer_coverage_mapping_libcdep.cc.
* tsan/Makefile.am (tsan_files): Add tsan_external.cc.
* ubsan/Makefile.am (DEFS): Add -DUBSAN_CAN_USE_CXXABI=1.
(ubsan_files): Add ubsan_init_standalone.cc and
ubsan_signals_standalone.cc.
* ubsan/libtool-version: Bump the libubsan SONAME.
* asan/Makefile.in: Regenerate.
* lsan/Makefile.in: Regenerate.
* sanitizer_common/Makefile.in: Regenerate.
* tsan/Makefile.in: Regenerate.
* ubsan/Makefile.in: Regenerate.
From-SVN: r253887
2017-10-19 13:23:59 +02:00
|
|
|
return ret; \
|
2012-11-22 23:03:11 +01:00
|
|
|
ThreadState *thr = cur_thread(); \
|
2013-12-05 10:18:38 +01:00
|
|
|
const uptr caller_pc = (uptr)__builtin_return_address(0); \
|
2012-11-22 23:03:11 +01:00
|
|
|
StatInc(thr, StatAnnotation); \
|
|
|
|
StatInc(thr, Stat##typ); \
|
ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins...
* ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch
builtins, store max (log2 (align), 0) into uchar field instead of
align into uptr field.
(ubsan_expand_objsize_ifn): Use _v1 suffixed type mismatch builtins,
store uchar 0 field instead of uptr 0 field.
(instrument_nonnull_return): Use _v1 suffixed nonnull return builtin,
instead of passing one address of struct with 2 locations pass
two addresses of structs with 1 location each.
* sanitizer.def (BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH,
BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH_ABORT,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_ABORT): Removed.
(BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH_V1,
BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH_V1_ABORT,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_V1,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_V1_ABORT): New builtins.
* c-c++-common/ubsan/float-cast-overflow-1.c: Drop value keyword
from expected output regexps.
* c-c++-common/ubsan/float-cast-overflow-2.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-3.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-4.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-5.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-6.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-8.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-9.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-10.c: Likewise.
* g++.dg/ubsan/float-cast-overflow-bf.C: Likewise.
* gcc.dg/ubsan/float-cast-overflow-bf.c: Likewise.
* g++.dg/asan/default-options-1.C (__asan_default_options): Add
used attribute.
* g++.dg/asan/asan_test.C: Run with ASAN_OPTIONS=handle_segv=2
in the environment.
* All source files: Merge from upstream 315899.
* asan/Makefile.am (nodist_saninclude_HEADERS): Add
include/sanitizer/tsan_interface.h.
* asan/libtool-version: Bump the libasan SONAME.
* lsan/Makefile.am (sanitizer_lsan_files): Add lsan_common_mac.cc.
(lsan_files): Add lsan_linux.cc, lsan_mac.cc and lsan_malloc_mac.cc.
* sanitizer_common/Makefile.am (sanitizer_common_files): Add
sancov_flags.cc, sanitizer_allocator_checks.cc,
sanitizer_coverage_libcdep_new.cc, sanitizer_errno.cc,
sanitizer_file.cc, sanitizer_mac_libcdep.cc and
sanitizer_stoptheworld_mac.cc. Remove sanitizer_coverage_libcdep.cc
and sanitizer_coverage_mapping_libcdep.cc.
* tsan/Makefile.am (tsan_files): Add tsan_external.cc.
* ubsan/Makefile.am (DEFS): Add -DUBSAN_CAN_USE_CXXABI=1.
(ubsan_files): Add ubsan_init_standalone.cc and
ubsan_signals_standalone.cc.
* ubsan/libtool-version: Bump the libubsan SONAME.
* asan/Makefile.in: Regenerate.
* lsan/Makefile.in: Regenerate.
* sanitizer_common/Makefile.in: Regenerate.
* tsan/Makefile.in: Regenerate.
* ubsan/Makefile.in: Regenerate.
From-SVN: r253887
2017-10-19 13:23:59 +02:00
|
|
|
ScopedAnnotation sa(thr, __func__, caller_pc); \
|
2014-11-13 21:41:38 +01:00
|
|
|
const uptr pc = StackTrace::GetCurrentPc(); \
|
2012-11-22 23:03:11 +01:00
|
|
|
(void)pc; \
|
|
|
|
/**/
|
|
|
|
|
ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins...
* ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch
builtins, store max (log2 (align), 0) into uchar field instead of
align into uptr field.
(ubsan_expand_objsize_ifn): Use _v1 suffixed type mismatch builtins,
store uchar 0 field instead of uptr 0 field.
(instrument_nonnull_return): Use _v1 suffixed nonnull return builtin,
instead of passing one address of struct with 2 locations pass
two addresses of structs with 1 location each.
* sanitizer.def (BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH,
BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH_ABORT,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_ABORT): Removed.
(BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH_V1,
BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH_V1_ABORT,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_V1,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_V1_ABORT): New builtins.
* c-c++-common/ubsan/float-cast-overflow-1.c: Drop value keyword
from expected output regexps.
* c-c++-common/ubsan/float-cast-overflow-2.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-3.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-4.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-5.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-6.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-8.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-9.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-10.c: Likewise.
* g++.dg/ubsan/float-cast-overflow-bf.C: Likewise.
* gcc.dg/ubsan/float-cast-overflow-bf.c: Likewise.
* g++.dg/asan/default-options-1.C (__asan_default_options): Add
used attribute.
* g++.dg/asan/asan_test.C: Run with ASAN_OPTIONS=handle_segv=2
in the environment.
* All source files: Merge from upstream 315899.
* asan/Makefile.am (nodist_saninclude_HEADERS): Add
include/sanitizer/tsan_interface.h.
* asan/libtool-version: Bump the libasan SONAME.
* lsan/Makefile.am (sanitizer_lsan_files): Add lsan_common_mac.cc.
(lsan_files): Add lsan_linux.cc, lsan_mac.cc and lsan_malloc_mac.cc.
* sanitizer_common/Makefile.am (sanitizer_common_files): Add
sancov_flags.cc, sanitizer_allocator_checks.cc,
sanitizer_coverage_libcdep_new.cc, sanitizer_errno.cc,
sanitizer_file.cc, sanitizer_mac_libcdep.cc and
sanitizer_stoptheworld_mac.cc. Remove sanitizer_coverage_libcdep.cc
and sanitizer_coverage_mapping_libcdep.cc.
* tsan/Makefile.am (tsan_files): Add tsan_external.cc.
* ubsan/Makefile.am (DEFS): Add -DUBSAN_CAN_USE_CXXABI=1.
(ubsan_files): Add ubsan_init_standalone.cc and
ubsan_signals_standalone.cc.
* ubsan/libtool-version: Bump the libubsan SONAME.
* asan/Makefile.in: Regenerate.
* lsan/Makefile.in: Regenerate.
* sanitizer_common/Makefile.in: Regenerate.
* tsan/Makefile.in: Regenerate.
* ubsan/Makefile.in: Regenerate.
From-SVN: r253887
2017-10-19 13:23:59 +02:00
|
|
|
#define SCOPED_ANNOTATION(typ) SCOPED_ANNOTATION_RET(typ, )
|
|
|
|
|
2012-11-22 23:03:11 +01:00
|
|
|
static const int kMaxDescLen = 128;
|
|
|
|
|
|
|
|
struct ExpectRace {
|
|
|
|
ExpectRace *next;
|
|
|
|
ExpectRace *prev;
|
2015-10-21 09:32:45 +02:00
|
|
|
atomic_uintptr_t hitcount;
|
|
|
|
atomic_uintptr_t addcount;
|
2012-11-22 23:03:11 +01:00
|
|
|
uptr addr;
|
|
|
|
uptr size;
|
|
|
|
char *file;
|
|
|
|
int line;
|
|
|
|
char desc[kMaxDescLen];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct DynamicAnnContext {
|
|
|
|
Mutex mtx;
|
|
|
|
ExpectRace expect;
|
|
|
|
ExpectRace benign;
|
|
|
|
|
|
|
|
DynamicAnnContext()
|
|
|
|
: mtx(MutexTypeAnnotations, StatMtxAnnotations) {
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static DynamicAnnContext *dyn_ann_ctx;
|
|
|
|
static char dyn_ann_ctx_placeholder[sizeof(DynamicAnnContext)] ALIGNED(64);
|
|
|
|
|
|
|
|
static void AddExpectRace(ExpectRace *list,
|
|
|
|
char *f, int l, uptr addr, uptr size, char *desc) {
|
|
|
|
ExpectRace *race = list->next;
|
|
|
|
for (; race != list; race = race->next) {
|
2013-11-04 22:33:31 +01:00
|
|
|
if (race->addr == addr && race->size == size) {
|
2015-10-21 09:32:45 +02:00
|
|
|
atomic_store_relaxed(&race->addcount,
|
|
|
|
atomic_load_relaxed(&race->addcount) + 1);
|
2012-11-22 23:03:11 +01:00
|
|
|
return;
|
2013-11-04 22:33:31 +01:00
|
|
|
}
|
2012-11-22 23:03:11 +01:00
|
|
|
}
|
|
|
|
race = (ExpectRace*)internal_alloc(MBlockExpectRace, sizeof(ExpectRace));
|
|
|
|
race->addr = addr;
|
|
|
|
race->size = size;
|
|
|
|
race->file = f;
|
|
|
|
race->line = l;
|
|
|
|
race->desc[0] = 0;
|
2015-10-21 09:32:45 +02:00
|
|
|
atomic_store_relaxed(&race->hitcount, 0);
|
|
|
|
atomic_store_relaxed(&race->addcount, 1);
|
2012-11-22 23:03:11 +01:00
|
|
|
if (desc) {
|
|
|
|
int i = 0;
|
|
|
|
for (; i < kMaxDescLen - 1 && desc[i]; i++)
|
|
|
|
race->desc[i] = desc[i];
|
|
|
|
race->desc[i] = 0;
|
|
|
|
}
|
|
|
|
race->prev = list;
|
|
|
|
race->next = list->next;
|
|
|
|
race->next->prev = race;
|
|
|
|
list->next = race;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ExpectRace *FindRace(ExpectRace *list, uptr addr, uptr size) {
|
|
|
|
for (ExpectRace *race = list->next; race != list; race = race->next) {
|
|
|
|
uptr maxbegin = max(race->addr, addr);
|
|
|
|
uptr minend = min(race->addr + race->size, addr + size);
|
|
|
|
if (maxbegin < minend)
|
|
|
|
return race;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool CheckContains(ExpectRace *list, uptr addr, uptr size) {
|
|
|
|
ExpectRace *race = FindRace(list, addr, size);
|
|
|
|
if (race == 0)
|
|
|
|
return false;
|
|
|
|
DPrintf("Hit expected/benign race: %s addr=%zx:%d %s:%d\n",
|
|
|
|
race->desc, race->addr, (int)race->size, race->file, race->line);
|
2015-10-21 09:32:45 +02:00
|
|
|
atomic_fetch_add(&race->hitcount, 1, memory_order_relaxed);
|
2012-11-22 23:03:11 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void InitList(ExpectRace *list) {
|
|
|
|
list->next = list;
|
|
|
|
list->prev = list;
|
|
|
|
}
|
|
|
|
|
|
|
|
void InitializeDynamicAnnotations() {
|
|
|
|
dyn_ann_ctx = new(dyn_ann_ctx_placeholder) DynamicAnnContext;
|
|
|
|
InitList(&dyn_ann_ctx->expect);
|
|
|
|
InitList(&dyn_ann_ctx->benign);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsExpectedReport(uptr addr, uptr size) {
|
2015-10-21 09:32:45 +02:00
|
|
|
ReadLock lock(&dyn_ann_ctx->mtx);
|
2012-11-22 23:03:11 +01:00
|
|
|
if (CheckContains(&dyn_ann_ctx->expect, addr, size))
|
|
|
|
return true;
|
|
|
|
if (CheckContains(&dyn_ann_ctx->benign, addr, size))
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-11-04 22:33:31 +01:00
|
|
|
static void CollectMatchedBenignRaces(Vector<ExpectRace> *matched,
|
2015-10-21 09:32:45 +02:00
|
|
|
int *unique_count, int *hit_count, atomic_uintptr_t ExpectRace::*counter) {
|
2013-11-04 22:33:31 +01:00
|
|
|
ExpectRace *list = &dyn_ann_ctx->benign;
|
|
|
|
for (ExpectRace *race = list->next; race != list; race = race->next) {
|
|
|
|
(*unique_count)++;
|
2015-10-21 09:32:45 +02:00
|
|
|
const uptr cnt = atomic_load_relaxed(&(race->*counter));
|
|
|
|
if (cnt == 0)
|
2013-11-04 22:33:31 +01:00
|
|
|
continue;
|
2015-10-21 09:32:45 +02:00
|
|
|
*hit_count += cnt;
|
2013-11-04 22:33:31 +01:00
|
|
|
uptr i = 0;
|
|
|
|
for (; i < matched->Size(); i++) {
|
|
|
|
ExpectRace *race0 = &(*matched)[i];
|
|
|
|
if (race->line == race0->line
|
|
|
|
&& internal_strcmp(race->file, race0->file) == 0
|
|
|
|
&& internal_strcmp(race->desc, race0->desc) == 0) {
|
2015-10-21 09:32:45 +02:00
|
|
|
atomic_fetch_add(&(race0->*counter), cnt, memory_order_relaxed);
|
2013-11-04 22:33:31 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i == matched->Size())
|
|
|
|
matched->PushBack(*race);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PrintMatchedBenignRaces() {
|
|
|
|
Lock lock(&dyn_ann_ctx->mtx);
|
|
|
|
int unique_count = 0;
|
|
|
|
int hit_count = 0;
|
|
|
|
int add_count = 0;
|
2018-10-31 12:14:23 +01:00
|
|
|
Vector<ExpectRace> hit_matched;
|
2013-11-04 22:33:31 +01:00
|
|
|
CollectMatchedBenignRaces(&hit_matched, &unique_count, &hit_count,
|
|
|
|
&ExpectRace::hitcount);
|
2018-10-31 12:14:23 +01:00
|
|
|
Vector<ExpectRace> add_matched;
|
2013-11-04 22:33:31 +01:00
|
|
|
CollectMatchedBenignRaces(&add_matched, &unique_count, &add_count,
|
|
|
|
&ExpectRace::addcount);
|
|
|
|
if (hit_matched.Size()) {
|
|
|
|
Printf("ThreadSanitizer: Matched %d \"benign\" races (pid=%d):\n",
|
|
|
|
hit_count, (int)internal_getpid());
|
|
|
|
for (uptr i = 0; i < hit_matched.Size(); i++) {
|
|
|
|
Printf("%d %s:%d %s\n",
|
2015-10-21 09:32:45 +02:00
|
|
|
atomic_load_relaxed(&hit_matched[i].hitcount),
|
|
|
|
hit_matched[i].file, hit_matched[i].line, hit_matched[i].desc);
|
2013-11-04 22:33:31 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (hit_matched.Size()) {
|
|
|
|
Printf("ThreadSanitizer: Annotated %d \"benign\" races, %d unique"
|
|
|
|
" (pid=%d):\n",
|
|
|
|
add_count, unique_count, (int)internal_getpid());
|
|
|
|
for (uptr i = 0; i < add_matched.Size(); i++) {
|
|
|
|
Printf("%d %s:%d %s\n",
|
2015-10-21 09:32:45 +02:00
|
|
|
atomic_load_relaxed(&add_matched[i].addcount),
|
|
|
|
add_matched[i].file, add_matched[i].line, add_matched[i].desc);
|
2013-11-04 22:33:31 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ReportMissedExpectedRace(ExpectRace *race) {
|
|
|
|
Printf("==================\n");
|
|
|
|
Printf("WARNING: ThreadSanitizer: missed expected data race\n");
|
|
|
|
Printf(" %s addr=%zx %s:%d\n",
|
|
|
|
race->desc, race->addr, race->file, race->line);
|
|
|
|
Printf("==================\n");
|
|
|
|
}
|
2012-11-22 23:03:11 +01:00
|
|
|
} // namespace __tsan
|
|
|
|
|
2019-11-05 14:54:57 +01:00
|
|
|
using namespace __tsan;
|
2012-11-22 23:03:11 +01:00
|
|
|
|
|
|
|
extern "C" {
|
2012-12-05 14:19:55 +01:00
|
|
|
void INTERFACE_ATTRIBUTE AnnotateHappensBefore(char *f, int l, uptr addr) {
|
2012-11-22 23:03:11 +01:00
|
|
|
SCOPED_ANNOTATION(AnnotateHappensBefore);
|
2013-11-04 22:33:31 +01:00
|
|
|
Release(thr, pc, addr);
|
2012-11-22 23:03:11 +01:00
|
|
|
}
|
|
|
|
|
2012-12-05 14:19:55 +01:00
|
|
|
void INTERFACE_ATTRIBUTE AnnotateHappensAfter(char *f, int l, uptr addr) {
|
2012-11-22 23:03:11 +01:00
|
|
|
SCOPED_ANNOTATION(AnnotateHappensAfter);
|
2013-11-04 22:33:31 +01:00
|
|
|
Acquire(thr, pc, addr);
|
2012-11-22 23:03:11 +01:00
|
|
|
}
|
|
|
|
|
2012-12-05 14:19:55 +01:00
|
|
|
void INTERFACE_ATTRIBUTE AnnotateCondVarSignal(char *f, int l, uptr cv) {
|
2012-11-22 23:03:11 +01:00
|
|
|
SCOPED_ANNOTATION(AnnotateCondVarSignal);
|
|
|
|
}
|
|
|
|
|
2012-12-05 14:19:55 +01:00
|
|
|
void INTERFACE_ATTRIBUTE AnnotateCondVarSignalAll(char *f, int l, uptr cv) {
|
2012-11-22 23:03:11 +01:00
|
|
|
SCOPED_ANNOTATION(AnnotateCondVarSignalAll);
|
|
|
|
}
|
|
|
|
|
2012-12-05 14:19:55 +01:00
|
|
|
void INTERFACE_ATTRIBUTE AnnotateMutexIsNotPHB(char *f, int l, uptr mu) {
|
2012-11-22 23:03:11 +01:00
|
|
|
SCOPED_ANNOTATION(AnnotateMutexIsNotPHB);
|
|
|
|
}
|
|
|
|
|
2012-12-05 14:19:55 +01:00
|
|
|
void INTERFACE_ATTRIBUTE AnnotateCondVarWait(char *f, int l, uptr cv,
|
|
|
|
uptr lock) {
|
2012-11-22 23:03:11 +01:00
|
|
|
SCOPED_ANNOTATION(AnnotateCondVarWait);
|
|
|
|
}
|
|
|
|
|
2012-12-05 14:19:55 +01:00
|
|
|
void INTERFACE_ATTRIBUTE AnnotateRWLockCreate(char *f, int l, uptr m) {
|
2012-11-22 23:03:11 +01:00
|
|
|
SCOPED_ANNOTATION(AnnotateRWLockCreate);
|
ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins...
* ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch
builtins, store max (log2 (align), 0) into uchar field instead of
align into uptr field.
(ubsan_expand_objsize_ifn): Use _v1 suffixed type mismatch builtins,
store uchar 0 field instead of uptr 0 field.
(instrument_nonnull_return): Use _v1 suffixed nonnull return builtin,
instead of passing one address of struct with 2 locations pass
two addresses of structs with 1 location each.
* sanitizer.def (BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH,
BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH_ABORT,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_ABORT): Removed.
(BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH_V1,
BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH_V1_ABORT,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_V1,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_V1_ABORT): New builtins.
* c-c++-common/ubsan/float-cast-overflow-1.c: Drop value keyword
from expected output regexps.
* c-c++-common/ubsan/float-cast-overflow-2.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-3.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-4.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-5.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-6.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-8.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-9.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-10.c: Likewise.
* g++.dg/ubsan/float-cast-overflow-bf.C: Likewise.
* gcc.dg/ubsan/float-cast-overflow-bf.c: Likewise.
* g++.dg/asan/default-options-1.C (__asan_default_options): Add
used attribute.
* g++.dg/asan/asan_test.C: Run with ASAN_OPTIONS=handle_segv=2
in the environment.
* All source files: Merge from upstream 315899.
* asan/Makefile.am (nodist_saninclude_HEADERS): Add
include/sanitizer/tsan_interface.h.
* asan/libtool-version: Bump the libasan SONAME.
* lsan/Makefile.am (sanitizer_lsan_files): Add lsan_common_mac.cc.
(lsan_files): Add lsan_linux.cc, lsan_mac.cc and lsan_malloc_mac.cc.
* sanitizer_common/Makefile.am (sanitizer_common_files): Add
sancov_flags.cc, sanitizer_allocator_checks.cc,
sanitizer_coverage_libcdep_new.cc, sanitizer_errno.cc,
sanitizer_file.cc, sanitizer_mac_libcdep.cc and
sanitizer_stoptheworld_mac.cc. Remove sanitizer_coverage_libcdep.cc
and sanitizer_coverage_mapping_libcdep.cc.
* tsan/Makefile.am (tsan_files): Add tsan_external.cc.
* ubsan/Makefile.am (DEFS): Add -DUBSAN_CAN_USE_CXXABI=1.
(ubsan_files): Add ubsan_init_standalone.cc and
ubsan_signals_standalone.cc.
* ubsan/libtool-version: Bump the libubsan SONAME.
* asan/Makefile.in: Regenerate.
* lsan/Makefile.in: Regenerate.
* sanitizer_common/Makefile.in: Regenerate.
* tsan/Makefile.in: Regenerate.
* ubsan/Makefile.in: Regenerate.
From-SVN: r253887
2017-10-19 13:23:59 +02:00
|
|
|
MutexCreate(thr, pc, m, MutexFlagWriteReentrant);
|
2012-11-22 23:03:11 +01:00
|
|
|
}
|
|
|
|
|
2012-12-05 14:19:55 +01:00
|
|
|
void INTERFACE_ATTRIBUTE AnnotateRWLockCreateStatic(char *f, int l, uptr m) {
|
2012-11-22 23:03:11 +01:00
|
|
|
SCOPED_ANNOTATION(AnnotateRWLockCreateStatic);
|
ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins...
* ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch
builtins, store max (log2 (align), 0) into uchar field instead of
align into uptr field.
(ubsan_expand_objsize_ifn): Use _v1 suffixed type mismatch builtins,
store uchar 0 field instead of uptr 0 field.
(instrument_nonnull_return): Use _v1 suffixed nonnull return builtin,
instead of passing one address of struct with 2 locations pass
two addresses of structs with 1 location each.
* sanitizer.def (BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH,
BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH_ABORT,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_ABORT): Removed.
(BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH_V1,
BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH_V1_ABORT,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_V1,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_V1_ABORT): New builtins.
* c-c++-common/ubsan/float-cast-overflow-1.c: Drop value keyword
from expected output regexps.
* c-c++-common/ubsan/float-cast-overflow-2.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-3.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-4.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-5.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-6.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-8.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-9.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-10.c: Likewise.
* g++.dg/ubsan/float-cast-overflow-bf.C: Likewise.
* gcc.dg/ubsan/float-cast-overflow-bf.c: Likewise.
* g++.dg/asan/default-options-1.C (__asan_default_options): Add
used attribute.
* g++.dg/asan/asan_test.C: Run with ASAN_OPTIONS=handle_segv=2
in the environment.
* All source files: Merge from upstream 315899.
* asan/Makefile.am (nodist_saninclude_HEADERS): Add
include/sanitizer/tsan_interface.h.
* asan/libtool-version: Bump the libasan SONAME.
* lsan/Makefile.am (sanitizer_lsan_files): Add lsan_common_mac.cc.
(lsan_files): Add lsan_linux.cc, lsan_mac.cc and lsan_malloc_mac.cc.
* sanitizer_common/Makefile.am (sanitizer_common_files): Add
sancov_flags.cc, sanitizer_allocator_checks.cc,
sanitizer_coverage_libcdep_new.cc, sanitizer_errno.cc,
sanitizer_file.cc, sanitizer_mac_libcdep.cc and
sanitizer_stoptheworld_mac.cc. Remove sanitizer_coverage_libcdep.cc
and sanitizer_coverage_mapping_libcdep.cc.
* tsan/Makefile.am (tsan_files): Add tsan_external.cc.
* ubsan/Makefile.am (DEFS): Add -DUBSAN_CAN_USE_CXXABI=1.
(ubsan_files): Add ubsan_init_standalone.cc and
ubsan_signals_standalone.cc.
* ubsan/libtool-version: Bump the libubsan SONAME.
* asan/Makefile.in: Regenerate.
* lsan/Makefile.in: Regenerate.
* sanitizer_common/Makefile.in: Regenerate.
* tsan/Makefile.in: Regenerate.
* ubsan/Makefile.in: Regenerate.
From-SVN: r253887
2017-10-19 13:23:59 +02:00
|
|
|
MutexCreate(thr, pc, m, MutexFlagWriteReentrant | MutexFlagLinkerInit);
|
2012-11-22 23:03:11 +01:00
|
|
|
}
|
|
|
|
|
2012-12-05 14:19:55 +01:00
|
|
|
void INTERFACE_ATTRIBUTE AnnotateRWLockDestroy(char *f, int l, uptr m) {
|
2012-11-22 23:03:11 +01:00
|
|
|
SCOPED_ANNOTATION(AnnotateRWLockDestroy);
|
|
|
|
MutexDestroy(thr, pc, m);
|
|
|
|
}
|
|
|
|
|
2012-12-05 14:19:55 +01:00
|
|
|
void INTERFACE_ATTRIBUTE AnnotateRWLockAcquired(char *f, int l, uptr m,
|
|
|
|
uptr is_w) {
|
2012-11-22 23:03:11 +01:00
|
|
|
SCOPED_ANNOTATION(AnnotateRWLockAcquired);
|
|
|
|
if (is_w)
|
ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins...
* ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch
builtins, store max (log2 (align), 0) into uchar field instead of
align into uptr field.
(ubsan_expand_objsize_ifn): Use _v1 suffixed type mismatch builtins,
store uchar 0 field instead of uptr 0 field.
(instrument_nonnull_return): Use _v1 suffixed nonnull return builtin,
instead of passing one address of struct with 2 locations pass
two addresses of structs with 1 location each.
* sanitizer.def (BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH,
BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH_ABORT,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_ABORT): Removed.
(BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH_V1,
BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH_V1_ABORT,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_V1,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_V1_ABORT): New builtins.
* c-c++-common/ubsan/float-cast-overflow-1.c: Drop value keyword
from expected output regexps.
* c-c++-common/ubsan/float-cast-overflow-2.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-3.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-4.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-5.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-6.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-8.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-9.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-10.c: Likewise.
* g++.dg/ubsan/float-cast-overflow-bf.C: Likewise.
* gcc.dg/ubsan/float-cast-overflow-bf.c: Likewise.
* g++.dg/asan/default-options-1.C (__asan_default_options): Add
used attribute.
* g++.dg/asan/asan_test.C: Run with ASAN_OPTIONS=handle_segv=2
in the environment.
* All source files: Merge from upstream 315899.
* asan/Makefile.am (nodist_saninclude_HEADERS): Add
include/sanitizer/tsan_interface.h.
* asan/libtool-version: Bump the libasan SONAME.
* lsan/Makefile.am (sanitizer_lsan_files): Add lsan_common_mac.cc.
(lsan_files): Add lsan_linux.cc, lsan_mac.cc and lsan_malloc_mac.cc.
* sanitizer_common/Makefile.am (sanitizer_common_files): Add
sancov_flags.cc, sanitizer_allocator_checks.cc,
sanitizer_coverage_libcdep_new.cc, sanitizer_errno.cc,
sanitizer_file.cc, sanitizer_mac_libcdep.cc and
sanitizer_stoptheworld_mac.cc. Remove sanitizer_coverage_libcdep.cc
and sanitizer_coverage_mapping_libcdep.cc.
* tsan/Makefile.am (tsan_files): Add tsan_external.cc.
* ubsan/Makefile.am (DEFS): Add -DUBSAN_CAN_USE_CXXABI=1.
(ubsan_files): Add ubsan_init_standalone.cc and
ubsan_signals_standalone.cc.
* ubsan/libtool-version: Bump the libubsan SONAME.
* asan/Makefile.in: Regenerate.
* lsan/Makefile.in: Regenerate.
* sanitizer_common/Makefile.in: Regenerate.
* tsan/Makefile.in: Regenerate.
* ubsan/Makefile.in: Regenerate.
From-SVN: r253887
2017-10-19 13:23:59 +02:00
|
|
|
MutexPostLock(thr, pc, m, MutexFlagDoPreLockOnPostLock);
|
2012-11-22 23:03:11 +01:00
|
|
|
else
|
ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins...
* ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch
builtins, store max (log2 (align), 0) into uchar field instead of
align into uptr field.
(ubsan_expand_objsize_ifn): Use _v1 suffixed type mismatch builtins,
store uchar 0 field instead of uptr 0 field.
(instrument_nonnull_return): Use _v1 suffixed nonnull return builtin,
instead of passing one address of struct with 2 locations pass
two addresses of structs with 1 location each.
* sanitizer.def (BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH,
BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH_ABORT,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_ABORT): Removed.
(BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH_V1,
BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH_V1_ABORT,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_V1,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_V1_ABORT): New builtins.
* c-c++-common/ubsan/float-cast-overflow-1.c: Drop value keyword
from expected output regexps.
* c-c++-common/ubsan/float-cast-overflow-2.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-3.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-4.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-5.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-6.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-8.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-9.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-10.c: Likewise.
* g++.dg/ubsan/float-cast-overflow-bf.C: Likewise.
* gcc.dg/ubsan/float-cast-overflow-bf.c: Likewise.
* g++.dg/asan/default-options-1.C (__asan_default_options): Add
used attribute.
* g++.dg/asan/asan_test.C: Run with ASAN_OPTIONS=handle_segv=2
in the environment.
* All source files: Merge from upstream 315899.
* asan/Makefile.am (nodist_saninclude_HEADERS): Add
include/sanitizer/tsan_interface.h.
* asan/libtool-version: Bump the libasan SONAME.
* lsan/Makefile.am (sanitizer_lsan_files): Add lsan_common_mac.cc.
(lsan_files): Add lsan_linux.cc, lsan_mac.cc and lsan_malloc_mac.cc.
* sanitizer_common/Makefile.am (sanitizer_common_files): Add
sancov_flags.cc, sanitizer_allocator_checks.cc,
sanitizer_coverage_libcdep_new.cc, sanitizer_errno.cc,
sanitizer_file.cc, sanitizer_mac_libcdep.cc and
sanitizer_stoptheworld_mac.cc. Remove sanitizer_coverage_libcdep.cc
and sanitizer_coverage_mapping_libcdep.cc.
* tsan/Makefile.am (tsan_files): Add tsan_external.cc.
* ubsan/Makefile.am (DEFS): Add -DUBSAN_CAN_USE_CXXABI=1.
(ubsan_files): Add ubsan_init_standalone.cc and
ubsan_signals_standalone.cc.
* ubsan/libtool-version: Bump the libubsan SONAME.
* asan/Makefile.in: Regenerate.
* lsan/Makefile.in: Regenerate.
* sanitizer_common/Makefile.in: Regenerate.
* tsan/Makefile.in: Regenerate.
* ubsan/Makefile.in: Regenerate.
From-SVN: r253887
2017-10-19 13:23:59 +02:00
|
|
|
MutexPostReadLock(thr, pc, m, MutexFlagDoPreLockOnPostLock);
|
2012-11-22 23:03:11 +01:00
|
|
|
}
|
|
|
|
|
2012-12-05 14:19:55 +01:00
|
|
|
void INTERFACE_ATTRIBUTE AnnotateRWLockReleased(char *f, int l, uptr m,
|
|
|
|
uptr is_w) {
|
2012-11-22 23:03:11 +01:00
|
|
|
SCOPED_ANNOTATION(AnnotateRWLockReleased);
|
|
|
|
if (is_w)
|
|
|
|
MutexUnlock(thr, pc, m);
|
|
|
|
else
|
|
|
|
MutexReadUnlock(thr, pc, m);
|
|
|
|
}
|
|
|
|
|
2012-12-05 14:19:55 +01:00
|
|
|
void INTERFACE_ATTRIBUTE AnnotateTraceMemory(char *f, int l, uptr mem) {
|
2012-11-22 23:03:11 +01:00
|
|
|
SCOPED_ANNOTATION(AnnotateTraceMemory);
|
|
|
|
}
|
|
|
|
|
2012-12-05 14:19:55 +01:00
|
|
|
void INTERFACE_ATTRIBUTE AnnotateFlushState(char *f, int l) {
|
2012-11-22 23:03:11 +01:00
|
|
|
SCOPED_ANNOTATION(AnnotateFlushState);
|
|
|
|
}
|
|
|
|
|
2012-12-05 14:19:55 +01:00
|
|
|
void INTERFACE_ATTRIBUTE AnnotateNewMemory(char *f, int l, uptr mem,
|
|
|
|
uptr size) {
|
2012-11-22 23:03:11 +01:00
|
|
|
SCOPED_ANNOTATION(AnnotateNewMemory);
|
|
|
|
}
|
|
|
|
|
2012-12-05 14:19:55 +01:00
|
|
|
void INTERFACE_ATTRIBUTE AnnotateNoOp(char *f, int l, uptr mem) {
|
2012-11-22 23:03:11 +01:00
|
|
|
SCOPED_ANNOTATION(AnnotateNoOp);
|
|
|
|
}
|
|
|
|
|
2012-12-05 14:19:55 +01:00
|
|
|
void INTERFACE_ATTRIBUTE AnnotateFlushExpectedRaces(char *f, int l) {
|
2012-11-22 23:03:11 +01:00
|
|
|
SCOPED_ANNOTATION(AnnotateFlushExpectedRaces);
|
|
|
|
Lock lock(&dyn_ann_ctx->mtx);
|
|
|
|
while (dyn_ann_ctx->expect.next != &dyn_ann_ctx->expect) {
|
|
|
|
ExpectRace *race = dyn_ann_ctx->expect.next;
|
2015-10-21 09:32:45 +02:00
|
|
|
if (atomic_load_relaxed(&race->hitcount) == 0) {
|
2014-05-22 09:09:21 +02:00
|
|
|
ctx->nmissed_expected++;
|
2012-11-22 23:03:11 +01:00
|
|
|
ReportMissedExpectedRace(race);
|
|
|
|
}
|
|
|
|
race->prev->next = race->next;
|
|
|
|
race->next->prev = race->prev;
|
|
|
|
internal_free(race);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-05 14:19:55 +01:00
|
|
|
void INTERFACE_ATTRIBUTE AnnotateEnableRaceDetection(
|
|
|
|
char *f, int l, int enable) {
|
2012-11-22 23:03:11 +01:00
|
|
|
SCOPED_ANNOTATION(AnnotateEnableRaceDetection);
|
|
|
|
// FIXME: Reconsider this functionality later. It may be irrelevant.
|
|
|
|
}
|
|
|
|
|
2012-12-05 14:19:55 +01:00
|
|
|
void INTERFACE_ATTRIBUTE AnnotateMutexIsUsedAsCondVar(
|
|
|
|
char *f, int l, uptr mu) {
|
2012-11-22 23:03:11 +01:00
|
|
|
SCOPED_ANNOTATION(AnnotateMutexIsUsedAsCondVar);
|
|
|
|
}
|
|
|
|
|
2012-12-05 14:19:55 +01:00
|
|
|
void INTERFACE_ATTRIBUTE AnnotatePCQGet(
|
|
|
|
char *f, int l, uptr pcq) {
|
2012-11-22 23:03:11 +01:00
|
|
|
SCOPED_ANNOTATION(AnnotatePCQGet);
|
|
|
|
}
|
|
|
|
|
2012-12-05 14:19:55 +01:00
|
|
|
void INTERFACE_ATTRIBUTE AnnotatePCQPut(
|
|
|
|
char *f, int l, uptr pcq) {
|
2012-11-22 23:03:11 +01:00
|
|
|
SCOPED_ANNOTATION(AnnotatePCQPut);
|
|
|
|
}
|
|
|
|
|
2012-12-05 14:19:55 +01:00
|
|
|
void INTERFACE_ATTRIBUTE AnnotatePCQDestroy(
|
|
|
|
char *f, int l, uptr pcq) {
|
2012-11-22 23:03:11 +01:00
|
|
|
SCOPED_ANNOTATION(AnnotatePCQDestroy);
|
|
|
|
}
|
|
|
|
|
2012-12-05 14:19:55 +01:00
|
|
|
void INTERFACE_ATTRIBUTE AnnotatePCQCreate(
|
|
|
|
char *f, int l, uptr pcq) {
|
2012-11-22 23:03:11 +01:00
|
|
|
SCOPED_ANNOTATION(AnnotatePCQCreate);
|
|
|
|
}
|
|
|
|
|
2012-12-05 14:19:55 +01:00
|
|
|
void INTERFACE_ATTRIBUTE AnnotateExpectRace(
|
|
|
|
char *f, int l, uptr mem, char *desc) {
|
2012-11-22 23:03:11 +01:00
|
|
|
SCOPED_ANNOTATION(AnnotateExpectRace);
|
|
|
|
Lock lock(&dyn_ann_ctx->mtx);
|
|
|
|
AddExpectRace(&dyn_ann_ctx->expect,
|
|
|
|
f, l, mem, 1, desc);
|
|
|
|
DPrintf("Add expected race: %s addr=%zx %s:%d\n", desc, mem, f, l);
|
|
|
|
}
|
|
|
|
|
2012-12-05 14:19:55 +01:00
|
|
|
static void BenignRaceImpl(
|
|
|
|
char *f, int l, uptr mem, uptr size, char *desc) {
|
2012-11-22 23:03:11 +01:00
|
|
|
Lock lock(&dyn_ann_ctx->mtx);
|
|
|
|
AddExpectRace(&dyn_ann_ctx->benign,
|
|
|
|
f, l, mem, size, desc);
|
|
|
|
DPrintf("Add benign race: %s addr=%zx %s:%d\n", desc, mem, f, l);
|
|
|
|
}
|
|
|
|
|
|
|
|
// FIXME: Turn it off later. WTF is benign race?1?? Go talk to Hans Boehm.
|
2012-12-05 14:19:55 +01:00
|
|
|
void INTERFACE_ATTRIBUTE AnnotateBenignRaceSized(
|
|
|
|
char *f, int l, uptr mem, uptr size, char *desc) {
|
2012-11-22 23:03:11 +01:00
|
|
|
SCOPED_ANNOTATION(AnnotateBenignRaceSized);
|
|
|
|
BenignRaceImpl(f, l, mem, size, desc);
|
|
|
|
}
|
|
|
|
|
2012-12-05 14:19:55 +01:00
|
|
|
void INTERFACE_ATTRIBUTE AnnotateBenignRace(
|
|
|
|
char *f, int l, uptr mem, char *desc) {
|
2012-11-22 23:03:11 +01:00
|
|
|
SCOPED_ANNOTATION(AnnotateBenignRace);
|
|
|
|
BenignRaceImpl(f, l, mem, 1, desc);
|
|
|
|
}
|
|
|
|
|
2012-12-05 14:19:55 +01:00
|
|
|
void INTERFACE_ATTRIBUTE AnnotateIgnoreReadsBegin(char *f, int l) {
|
2012-11-22 23:03:11 +01:00
|
|
|
SCOPED_ANNOTATION(AnnotateIgnoreReadsBegin);
|
2013-12-05 10:18:38 +01:00
|
|
|
ThreadIgnoreBegin(thr, pc);
|
2012-11-22 23:03:11 +01:00
|
|
|
}
|
|
|
|
|
2012-12-05 14:19:55 +01:00
|
|
|
void INTERFACE_ATTRIBUTE AnnotateIgnoreReadsEnd(char *f, int l) {
|
2012-11-22 23:03:11 +01:00
|
|
|
SCOPED_ANNOTATION(AnnotateIgnoreReadsEnd);
|
2013-12-05 10:18:38 +01:00
|
|
|
ThreadIgnoreEnd(thr, pc);
|
2012-11-22 23:03:11 +01:00
|
|
|
}
|
|
|
|
|
2012-12-05 14:19:55 +01:00
|
|
|
void INTERFACE_ATTRIBUTE AnnotateIgnoreWritesBegin(char *f, int l) {
|
2012-11-22 23:03:11 +01:00
|
|
|
SCOPED_ANNOTATION(AnnotateIgnoreWritesBegin);
|
2013-12-05 10:18:38 +01:00
|
|
|
ThreadIgnoreBegin(thr, pc);
|
2012-11-22 23:03:11 +01:00
|
|
|
}
|
|
|
|
|
2012-12-05 14:19:55 +01:00
|
|
|
void INTERFACE_ATTRIBUTE AnnotateIgnoreWritesEnd(char *f, int l) {
|
2012-11-22 23:03:11 +01:00
|
|
|
SCOPED_ANNOTATION(AnnotateIgnoreWritesEnd);
|
2013-12-05 10:18:38 +01:00
|
|
|
ThreadIgnoreEnd(thr, pc);
|
|
|
|
}
|
|
|
|
|
|
|
|
void INTERFACE_ATTRIBUTE AnnotateIgnoreSyncBegin(char *f, int l) {
|
|
|
|
SCOPED_ANNOTATION(AnnotateIgnoreSyncBegin);
|
|
|
|
ThreadIgnoreSyncBegin(thr, pc);
|
|
|
|
}
|
|
|
|
|
|
|
|
void INTERFACE_ATTRIBUTE AnnotateIgnoreSyncEnd(char *f, int l) {
|
|
|
|
SCOPED_ANNOTATION(AnnotateIgnoreSyncEnd);
|
|
|
|
ThreadIgnoreSyncEnd(thr, pc);
|
2012-11-22 23:03:11 +01:00
|
|
|
}
|
|
|
|
|
2012-12-05 14:19:55 +01:00
|
|
|
void INTERFACE_ATTRIBUTE AnnotatePublishMemoryRange(
|
|
|
|
char *f, int l, uptr addr, uptr size) {
|
2012-11-22 23:03:11 +01:00
|
|
|
SCOPED_ANNOTATION(AnnotatePublishMemoryRange);
|
|
|
|
}
|
|
|
|
|
2012-12-05 14:19:55 +01:00
|
|
|
void INTERFACE_ATTRIBUTE AnnotateUnpublishMemoryRange(
|
|
|
|
char *f, int l, uptr addr, uptr size) {
|
2012-11-22 23:03:11 +01:00
|
|
|
SCOPED_ANNOTATION(AnnotateUnpublishMemoryRange);
|
|
|
|
}
|
|
|
|
|
2012-12-05 14:19:55 +01:00
|
|
|
void INTERFACE_ATTRIBUTE AnnotateThreadName(
|
|
|
|
char *f, int l, char *name) {
|
2012-11-22 23:03:11 +01:00
|
|
|
SCOPED_ANNOTATION(AnnotateThreadName);
|
2012-12-05 14:19:55 +01:00
|
|
|
ThreadSetName(thr, name);
|
2012-11-22 23:03:11 +01:00
|
|
|
}
|
|
|
|
|
2013-11-04 22:33:31 +01:00
|
|
|
// We deliberately omit the implementation of WTFAnnotateHappensBefore() and
|
|
|
|
// WTFAnnotateHappensAfter(). Those are being used by Webkit to annotate
|
|
|
|
// atomic operations, which should be handled by ThreadSanitizer correctly.
|
2012-12-05 14:19:55 +01:00
|
|
|
void INTERFACE_ATTRIBUTE WTFAnnotateHappensBefore(char *f, int l, uptr addr) {
|
2012-11-22 23:03:11 +01:00
|
|
|
SCOPED_ANNOTATION(AnnotateHappensBefore);
|
|
|
|
}
|
|
|
|
|
2012-12-05 14:19:55 +01:00
|
|
|
void INTERFACE_ATTRIBUTE WTFAnnotateHappensAfter(char *f, int l, uptr addr) {
|
2012-11-22 23:03:11 +01:00
|
|
|
SCOPED_ANNOTATION(AnnotateHappensAfter);
|
|
|
|
}
|
|
|
|
|
2012-12-05 14:19:55 +01:00
|
|
|
void INTERFACE_ATTRIBUTE WTFAnnotateBenignRaceSized(
|
|
|
|
char *f, int l, uptr mem, uptr sz, char *desc) {
|
2012-11-22 23:03:11 +01:00
|
|
|
SCOPED_ANNOTATION(AnnotateBenignRaceSized);
|
2013-12-05 10:18:38 +01:00
|
|
|
BenignRaceImpl(f, l, mem, sz, desc);
|
2012-11-22 23:03:11 +01:00
|
|
|
}
|
|
|
|
|
2012-12-05 14:19:55 +01:00
|
|
|
int INTERFACE_ATTRIBUTE RunningOnValgrind() {
|
2012-11-22 23:03:11 +01:00
|
|
|
return flags()->running_on_valgrind;
|
|
|
|
}
|
|
|
|
|
2012-12-05 14:19:55 +01:00
|
|
|
double __attribute__((weak)) INTERFACE_ATTRIBUTE ValgrindSlowdown(void) {
|
2012-11-22 23:03:11 +01:00
|
|
|
return 10.0;
|
|
|
|
}
|
|
|
|
|
2012-12-05 14:19:55 +01:00
|
|
|
const char INTERFACE_ATTRIBUTE* ThreadSanitizerQuery(const char *query) {
|
2012-11-22 23:03:11 +01:00
|
|
|
if (internal_strcmp(query, "pure_happens_before") == 0)
|
|
|
|
return "1";
|
|
|
|
else
|
|
|
|
return "0";
|
|
|
|
}
|
2013-11-04 22:33:31 +01:00
|
|
|
|
|
|
|
void INTERFACE_ATTRIBUTE
|
|
|
|
AnnotateMemoryIsInitialized(char *f, int l, uptr mem, uptr sz) {}
|
2014-11-13 21:41:38 +01:00
|
|
|
void INTERFACE_ATTRIBUTE
|
|
|
|
AnnotateMemoryIsUninitialized(char *f, int l, uptr mem, uptr sz) {}
|
ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch builtins...
* ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch
builtins, store max (log2 (align), 0) into uchar field instead of
align into uptr field.
(ubsan_expand_objsize_ifn): Use _v1 suffixed type mismatch builtins,
store uchar 0 field instead of uptr 0 field.
(instrument_nonnull_return): Use _v1 suffixed nonnull return builtin,
instead of passing one address of struct with 2 locations pass
two addresses of structs with 1 location each.
* sanitizer.def (BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH,
BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH_ABORT,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_ABORT): Removed.
(BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH_V1,
BUILT_IN_UBSAN_HANDLE_TYPE_MISMATCH_V1_ABORT,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_V1,
BUILT_IN_UBSAN_HANDLE_NONNULL_RETURN_V1_ABORT): New builtins.
* c-c++-common/ubsan/float-cast-overflow-1.c: Drop value keyword
from expected output regexps.
* c-c++-common/ubsan/float-cast-overflow-2.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-3.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-4.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-5.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-6.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-8.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-9.c: Likewise.
* c-c++-common/ubsan/float-cast-overflow-10.c: Likewise.
* g++.dg/ubsan/float-cast-overflow-bf.C: Likewise.
* gcc.dg/ubsan/float-cast-overflow-bf.c: Likewise.
* g++.dg/asan/default-options-1.C (__asan_default_options): Add
used attribute.
* g++.dg/asan/asan_test.C: Run with ASAN_OPTIONS=handle_segv=2
in the environment.
* All source files: Merge from upstream 315899.
* asan/Makefile.am (nodist_saninclude_HEADERS): Add
include/sanitizer/tsan_interface.h.
* asan/libtool-version: Bump the libasan SONAME.
* lsan/Makefile.am (sanitizer_lsan_files): Add lsan_common_mac.cc.
(lsan_files): Add lsan_linux.cc, lsan_mac.cc and lsan_malloc_mac.cc.
* sanitizer_common/Makefile.am (sanitizer_common_files): Add
sancov_flags.cc, sanitizer_allocator_checks.cc,
sanitizer_coverage_libcdep_new.cc, sanitizer_errno.cc,
sanitizer_file.cc, sanitizer_mac_libcdep.cc and
sanitizer_stoptheworld_mac.cc. Remove sanitizer_coverage_libcdep.cc
and sanitizer_coverage_mapping_libcdep.cc.
* tsan/Makefile.am (tsan_files): Add tsan_external.cc.
* ubsan/Makefile.am (DEFS): Add -DUBSAN_CAN_USE_CXXABI=1.
(ubsan_files): Add ubsan_init_standalone.cc and
ubsan_signals_standalone.cc.
* ubsan/libtool-version: Bump the libubsan SONAME.
* asan/Makefile.in: Regenerate.
* lsan/Makefile.in: Regenerate.
* sanitizer_common/Makefile.in: Regenerate.
* tsan/Makefile.in: Regenerate.
* ubsan/Makefile.in: Regenerate.
From-SVN: r253887
2017-10-19 13:23:59 +02:00
|
|
|
|
|
|
|
// Note: the parameter is called flagz, because flags is already taken
|
|
|
|
// by the global function that returns flags.
|
|
|
|
INTERFACE_ATTRIBUTE
|
|
|
|
void __tsan_mutex_create(void *m, unsigned flagz) {
|
|
|
|
SCOPED_ANNOTATION(__tsan_mutex_create);
|
|
|
|
MutexCreate(thr, pc, (uptr)m, flagz & MutexCreationFlagMask);
|
|
|
|
}
|
|
|
|
|
|
|
|
INTERFACE_ATTRIBUTE
|
|
|
|
void __tsan_mutex_destroy(void *m, unsigned flagz) {
|
|
|
|
SCOPED_ANNOTATION(__tsan_mutex_destroy);
|
|
|
|
MutexDestroy(thr, pc, (uptr)m, flagz);
|
|
|
|
}
|
|
|
|
|
|
|
|
INTERFACE_ATTRIBUTE
|
|
|
|
void __tsan_mutex_pre_lock(void *m, unsigned flagz) {
|
|
|
|
SCOPED_ANNOTATION(__tsan_mutex_pre_lock);
|
|
|
|
if (!(flagz & MutexFlagTryLock)) {
|
|
|
|
if (flagz & MutexFlagReadLock)
|
|
|
|
MutexPreReadLock(thr, pc, (uptr)m);
|
|
|
|
else
|
|
|
|
MutexPreLock(thr, pc, (uptr)m);
|
|
|
|
}
|
|
|
|
ThreadIgnoreBegin(thr, pc, /*save_stack=*/false);
|
|
|
|
ThreadIgnoreSyncBegin(thr, pc, /*save_stack=*/false);
|
|
|
|
}
|
|
|
|
|
|
|
|
INTERFACE_ATTRIBUTE
|
|
|
|
void __tsan_mutex_post_lock(void *m, unsigned flagz, int rec) {
|
|
|
|
SCOPED_ANNOTATION(__tsan_mutex_post_lock);
|
|
|
|
ThreadIgnoreSyncEnd(thr, pc);
|
|
|
|
ThreadIgnoreEnd(thr, pc);
|
|
|
|
if (!(flagz & MutexFlagTryLockFailed)) {
|
|
|
|
if (flagz & MutexFlagReadLock)
|
|
|
|
MutexPostReadLock(thr, pc, (uptr)m, flagz);
|
|
|
|
else
|
|
|
|
MutexPostLock(thr, pc, (uptr)m, flagz, rec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
INTERFACE_ATTRIBUTE
|
|
|
|
int __tsan_mutex_pre_unlock(void *m, unsigned flagz) {
|
|
|
|
SCOPED_ANNOTATION_RET(__tsan_mutex_pre_unlock, 0);
|
|
|
|
int ret = 0;
|
|
|
|
if (flagz & MutexFlagReadLock) {
|
|
|
|
CHECK(!(flagz & MutexFlagRecursiveUnlock));
|
|
|
|
MutexReadUnlock(thr, pc, (uptr)m);
|
|
|
|
} else {
|
|
|
|
ret = MutexUnlock(thr, pc, (uptr)m, flagz);
|
|
|
|
}
|
|
|
|
ThreadIgnoreBegin(thr, pc, /*save_stack=*/false);
|
|
|
|
ThreadIgnoreSyncBegin(thr, pc, /*save_stack=*/false);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
INTERFACE_ATTRIBUTE
|
|
|
|
void __tsan_mutex_post_unlock(void *m, unsigned flagz) {
|
|
|
|
SCOPED_ANNOTATION(__tsan_mutex_post_unlock);
|
|
|
|
ThreadIgnoreSyncEnd(thr, pc);
|
|
|
|
ThreadIgnoreEnd(thr, pc);
|
|
|
|
}
|
|
|
|
|
|
|
|
INTERFACE_ATTRIBUTE
|
|
|
|
void __tsan_mutex_pre_signal(void *addr, unsigned flagz) {
|
|
|
|
SCOPED_ANNOTATION(__tsan_mutex_pre_signal);
|
|
|
|
ThreadIgnoreBegin(thr, pc, /*save_stack=*/false);
|
|
|
|
ThreadIgnoreSyncBegin(thr, pc, /*save_stack=*/false);
|
|
|
|
}
|
|
|
|
|
|
|
|
INTERFACE_ATTRIBUTE
|
|
|
|
void __tsan_mutex_post_signal(void *addr, unsigned flagz) {
|
|
|
|
SCOPED_ANNOTATION(__tsan_mutex_post_signal);
|
|
|
|
ThreadIgnoreSyncEnd(thr, pc);
|
|
|
|
ThreadIgnoreEnd(thr, pc);
|
|
|
|
}
|
|
|
|
|
|
|
|
INTERFACE_ATTRIBUTE
|
|
|
|
void __tsan_mutex_pre_divert(void *addr, unsigned flagz) {
|
|
|
|
SCOPED_ANNOTATION(__tsan_mutex_pre_divert);
|
|
|
|
// Exit from ignore region started in __tsan_mutex_pre_lock/unlock/signal.
|
|
|
|
ThreadIgnoreSyncEnd(thr, pc);
|
|
|
|
ThreadIgnoreEnd(thr, pc);
|
|
|
|
}
|
|
|
|
|
|
|
|
INTERFACE_ATTRIBUTE
|
|
|
|
void __tsan_mutex_post_divert(void *addr, unsigned flagz) {
|
|
|
|
SCOPED_ANNOTATION(__tsan_mutex_post_divert);
|
|
|
|
ThreadIgnoreBegin(thr, pc, /*save_stack=*/false);
|
|
|
|
ThreadIgnoreSyncBegin(thr, pc, /*save_stack=*/false);
|
|
|
|
}
|
2012-11-22 23:03:11 +01:00
|
|
|
} // extern "C"
|