Date: Sun, 8 Jan 2017 19:47:17 +0000 (UTC) From: Dimitry Andric <dim@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r311697 - in projects/clang400-import/contrib/compiler-rt: include/sanitizer include/xray lib/asan lib/builtins lib/builtins/arm lib/cfi lib/dfsan lib/esan lib/interception lib/lsan lib... Message-ID: <201701081947.v08JlH08046885@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dim Date: Sun Jan 8 19:47:17 2017 New Revision: 311697 URL: https://svnweb.freebsd.org/changeset/base/311697 Log: Merge compiler-rt r291274. Added: projects/clang400-import/contrib/compiler-rt/include/xray/ - copied from r311696, vendor/compiler-rt/dist/include/xray/ projects/clang400-import/contrib/compiler-rt/lib/asan/asan_descriptions.cc - copied unchanged from r311696, vendor/compiler-rt/dist/lib/asan/asan_descriptions.cc projects/clang400-import/contrib/compiler-rt/lib/asan/asan_descriptions.h - copied unchanged from r311696, vendor/compiler-rt/dist/lib/asan/asan_descriptions.h projects/clang400-import/contrib/compiler-rt/lib/asan/asan_errors.cc - copied unchanged from r311696, vendor/compiler-rt/dist/lib/asan/asan_errors.cc projects/clang400-import/contrib/compiler-rt/lib/asan/asan_errors.h - copied unchanged from r311696, vendor/compiler-rt/dist/lib/asan/asan_errors.h projects/clang400-import/contrib/compiler-rt/lib/asan/asan_globals_win.cc - copied unchanged from r311696, vendor/compiler-rt/dist/lib/asan/asan_globals_win.cc projects/clang400-import/contrib/compiler-rt/lib/asan/asan_globals_win.h - copied unchanged from r311696, vendor/compiler-rt/dist/lib/asan/asan_globals_win.h projects/clang400-import/contrib/compiler-rt/lib/builtins/floattitf.c - copied unchanged from r311696, vendor/compiler-rt/dist/lib/builtins/floattitf.c projects/clang400-import/contrib/compiler-rt/lib/builtins/floatuntitf.c - copied unchanged from r311696, vendor/compiler-rt/dist/lib/builtins/floatuntitf.c projects/clang400-import/contrib/compiler-rt/lib/builtins/mingw_fixfloat.c - copied unchanged from r311696, vendor/compiler-rt/dist/lib/builtins/mingw_fixfloat.c projects/clang400-import/contrib/compiler-rt/lib/esan/esan_hashtable.h - copied unchanged from r311696, vendor/compiler-rt/dist/lib/esan/esan_hashtable.h projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sancov_flags.cc - copied unchanged from r311696, vendor/compiler-rt/dist/lib/sanitizer_common/sancov_flags.cc projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sancov_flags.h - copied unchanged from r311696, vendor/compiler-rt/dist/lib/sanitizer_common/sancov_flags.h projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sancov_flags.inc - copied unchanged from r311696, vendor/compiler-rt/dist/lib/sanitizer_common/sancov_flags.inc projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_allocator_bytemap.h - copied unchanged from r311696, vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_allocator_bytemap.h projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_allocator_combined.h - copied unchanged from r311696, vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_allocator_combined.h projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_allocator_local_cache.h - copied unchanged from r311696, vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_allocator_local_cache.h projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary32.h - copied unchanged from r311696, vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_allocator_primary32.h projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_allocator_primary64.h - copied unchanged from r311696, vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_allocator_primary64.h projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_allocator_secondary.h - copied unchanged from r311696, vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_allocator_secondary.h projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_allocator_size_class_map.h - copied unchanged from r311696, vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_allocator_size_class_map.h projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_allocator_stats.h - copied unchanged from r311696, vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_allocator_stats.h projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_coverage_libcdep_new.cc - copied unchanged from r311696, vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_coverage_libcdep_new.cc projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_dbghelp.h - copied unchanged from r311696, vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_dbghelp.h projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_linux_mips64.S - copied unchanged from r311696, vendor/compiler-rt/dist/lib/sanitizer_common/sanitizer_linux_mips64.S projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/symbolizer/ - copied from r311696, vendor/compiler-rt/dist/lib/sanitizer_common/symbolizer/ projects/clang400-import/contrib/compiler-rt/lib/scudo/scudo_allocator_secondary.h - copied unchanged from r311696, vendor/compiler-rt/dist/lib/scudo/scudo_allocator_secondary.h projects/clang400-import/contrib/compiler-rt/lib/tsan/rtl/tsan_rtl_mips64.S - copied unchanged from r311696, vendor/compiler-rt/dist/lib/tsan/rtl/tsan_rtl_mips64.S projects/clang400-import/contrib/compiler-rt/lib/xray/ - copied from r311696, vendor/compiler-rt/dist/lib/xray/ Modified: projects/clang400-import/contrib/compiler-rt/include/sanitizer/common_interface_defs.h projects/clang400-import/contrib/compiler-rt/include/sanitizer/coverage_interface.h projects/clang400-import/contrib/compiler-rt/lib/asan/asan_activation.cc projects/clang400-import/contrib/compiler-rt/lib/asan/asan_activation_flags.inc projects/clang400-import/contrib/compiler-rt/lib/asan/asan_allocator.cc projects/clang400-import/contrib/compiler-rt/lib/asan/asan_allocator.h projects/clang400-import/contrib/compiler-rt/lib/asan/asan_debugging.cc projects/clang400-import/contrib/compiler-rt/lib/asan/asan_fake_stack.cc projects/clang400-import/contrib/compiler-rt/lib/asan/asan_fake_stack.h projects/clang400-import/contrib/compiler-rt/lib/asan/asan_flags.cc projects/clang400-import/contrib/compiler-rt/lib/asan/asan_flags.inc projects/clang400-import/contrib/compiler-rt/lib/asan/asan_globals.cc projects/clang400-import/contrib/compiler-rt/lib/asan/asan_interceptors.cc projects/clang400-import/contrib/compiler-rt/lib/asan/asan_interface_internal.h projects/clang400-import/contrib/compiler-rt/lib/asan/asan_internal.h projects/clang400-import/contrib/compiler-rt/lib/asan/asan_mac.cc projects/clang400-import/contrib/compiler-rt/lib/asan/asan_malloc_linux.cc projects/clang400-import/contrib/compiler-rt/lib/asan/asan_malloc_win.cc projects/clang400-import/contrib/compiler-rt/lib/asan/asan_mapping.h projects/clang400-import/contrib/compiler-rt/lib/asan/asan_memory_profile.cc projects/clang400-import/contrib/compiler-rt/lib/asan/asan_new_delete.cc projects/clang400-import/contrib/compiler-rt/lib/asan/asan_poisoning.cc projects/clang400-import/contrib/compiler-rt/lib/asan/asan_poisoning.h projects/clang400-import/contrib/compiler-rt/lib/asan/asan_posix.cc projects/clang400-import/contrib/compiler-rt/lib/asan/asan_report.cc projects/clang400-import/contrib/compiler-rt/lib/asan/asan_report.h projects/clang400-import/contrib/compiler-rt/lib/asan/asan_rtl.cc projects/clang400-import/contrib/compiler-rt/lib/asan/asan_scariness_score.h projects/clang400-import/contrib/compiler-rt/lib/asan/asan_thread.cc projects/clang400-import/contrib/compiler-rt/lib/asan/asan_thread.h projects/clang400-import/contrib/compiler-rt/lib/asan/asan_win.cc projects/clang400-import/contrib/compiler-rt/lib/asan/asan_win_dll_thunk.cc projects/clang400-import/contrib/compiler-rt/lib/asan/asan_win_dynamic_runtime_thunk.cc projects/clang400-import/contrib/compiler-rt/lib/builtins/arm/aeabi_idivmod.S projects/clang400-import/contrib/compiler-rt/lib/builtins/arm/aeabi_ldivmod.S projects/clang400-import/contrib/compiler-rt/lib/builtins/arm/aeabi_uidivmod.S projects/clang400-import/contrib/compiler-rt/lib/builtins/arm/aeabi_uldivmod.S projects/clang400-import/contrib/compiler-rt/lib/builtins/arm/comparesf2.S projects/clang400-import/contrib/compiler-rt/lib/builtins/arm/divsi3.S projects/clang400-import/contrib/compiler-rt/lib/builtins/arm/udivsi3.S projects/clang400-import/contrib/compiler-rt/lib/builtins/assembly.h projects/clang400-import/contrib/compiler-rt/lib/builtins/atomic.c projects/clang400-import/contrib/compiler-rt/lib/builtins/clear_cache.c projects/clang400-import/contrib/compiler-rt/lib/builtins/int_lib.h projects/clang400-import/contrib/compiler-rt/lib/cfi/cfi.cc projects/clang400-import/contrib/compiler-rt/lib/dfsan/dfsan.cc projects/clang400-import/contrib/compiler-rt/lib/dfsan/dfsan.h projects/clang400-import/contrib/compiler-rt/lib/dfsan/dfsan_interceptors.cc projects/clang400-import/contrib/compiler-rt/lib/dfsan/dfsan_platform.h projects/clang400-import/contrib/compiler-rt/lib/dfsan/done_abilist.txt projects/clang400-import/contrib/compiler-rt/lib/esan/cache_frag.cpp projects/clang400-import/contrib/compiler-rt/lib/esan/esan.cpp projects/clang400-import/contrib/compiler-rt/lib/esan/esan.h projects/clang400-import/contrib/compiler-rt/lib/esan/esan_flags.cpp projects/clang400-import/contrib/compiler-rt/lib/esan/esan_interceptors.cpp projects/clang400-import/contrib/compiler-rt/lib/esan/esan_interface_internal.h projects/clang400-import/contrib/compiler-rt/lib/esan/esan_linux.cpp projects/clang400-import/contrib/compiler-rt/lib/esan/esan_shadow.h projects/clang400-import/contrib/compiler-rt/lib/interception/interception.h projects/clang400-import/contrib/compiler-rt/lib/interception/interception_win.cc projects/clang400-import/contrib/compiler-rt/lib/lsan/lsan_allocator.cc projects/clang400-import/contrib/compiler-rt/lib/lsan/lsan_common.cc projects/clang400-import/contrib/compiler-rt/lib/lsan/lsan_common_linux.cc projects/clang400-import/contrib/compiler-rt/lib/lsan/lsan_thread.cc projects/clang400-import/contrib/compiler-rt/lib/msan/msan.h projects/clang400-import/contrib/compiler-rt/lib/msan/msan_allocator.cc projects/clang400-import/contrib/compiler-rt/lib/msan/msan_interceptors.cc projects/clang400-import/contrib/compiler-rt/lib/msan/msan_interface_internal.h projects/clang400-import/contrib/compiler-rt/lib/msan/msan_linux.cc projects/clang400-import/contrib/compiler-rt/lib/profile/GCDAProfiling.c projects/clang400-import/contrib/compiler-rt/lib/profile/InstrProfData.inc projects/clang400-import/contrib/compiler-rt/lib/profile/InstrProfiling.c projects/clang400-import/contrib/compiler-rt/lib/profile/InstrProfiling.h projects/clang400-import/contrib/compiler-rt/lib/profile/InstrProfilingFile.c projects/clang400-import/contrib/compiler-rt/lib/profile/InstrProfilingInternal.h projects/clang400-import/contrib/compiler-rt/lib/profile/InstrProfilingPort.h projects/clang400-import/contrib/compiler-rt/lib/profile/InstrProfilingRuntime.cc projects/clang400-import/contrib/compiler-rt/lib/profile/InstrProfilingUtil.c projects/clang400-import/contrib/compiler-rt/lib/profile/InstrProfilingUtil.h projects/clang400-import/contrib/compiler-rt/lib/profile/InstrProfilingValue.c projects/clang400-import/contrib/compiler-rt/lib/profile/WindowsMMap.c projects/clang400-import/contrib/compiler-rt/lib/safestack/safestack.cc projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_addrhashmap.h projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_allocator.cc projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_allocator.h projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_allocator_interface.h projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_allocator_internal.h projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_atomic.h projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_common.cc projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_common.h projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_format.inc projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cc projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_common_nolibc.cc projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_coverage_libcdep.cc projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_flags.cc projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_flags.inc projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_interface_internal.h projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_libc.h projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_libignore.cc projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_linux.h projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_mac.h projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_malloc_mac.inc projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_platform.h projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_linux.cc projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cc projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_printf.cc projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_procmaps.h projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_freebsd.cc projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_linux.cc projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_procmaps_mac.cc projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_quarantine.h projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cc projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.cc projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cc projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.cc projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_printer.h projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cc projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_mac.cc projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_win.cc projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_thread_registry.cc projects/clang400-import/contrib/compiler-rt/lib/sanitizer_common/sanitizer_win.cc projects/clang400-import/contrib/compiler-rt/lib/scudo/scudo_allocator.cpp projects/clang400-import/contrib/compiler-rt/lib/scudo/scudo_allocator.h projects/clang400-import/contrib/compiler-rt/lib/scudo/scudo_flags.cpp projects/clang400-import/contrib/compiler-rt/lib/scudo/scudo_flags.h projects/clang400-import/contrib/compiler-rt/lib/scudo/scudo_interceptors.cpp projects/clang400-import/contrib/compiler-rt/lib/scudo/scudo_new_delete.cpp projects/clang400-import/contrib/compiler-rt/lib/scudo/scudo_termination.cpp projects/clang400-import/contrib/compiler-rt/lib/scudo/scudo_utils.cpp projects/clang400-import/contrib/compiler-rt/lib/scudo/scudo_utils.h projects/clang400-import/contrib/compiler-rt/lib/stats/stats_client.cc projects/clang400-import/contrib/compiler-rt/lib/tsan/go/tsan_go.cc projects/clang400-import/contrib/compiler-rt/lib/tsan/rtl/tsan_clock.cc projects/clang400-import/contrib/compiler-rt/lib/tsan/rtl/tsan_debugging.cc projects/clang400-import/contrib/compiler-rt/lib/tsan/rtl/tsan_defs.h projects/clang400-import/contrib/compiler-rt/lib/tsan/rtl/tsan_flags.cc projects/clang400-import/contrib/compiler-rt/lib/tsan/rtl/tsan_flags.inc projects/clang400-import/contrib/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc projects/clang400-import/contrib/compiler-rt/lib/tsan/rtl/tsan_interceptors_mac.cc projects/clang400-import/contrib/compiler-rt/lib/tsan/rtl/tsan_interface.h projects/clang400-import/contrib/compiler-rt/lib/tsan/rtl/tsan_interface_atomic.cc projects/clang400-import/contrib/compiler-rt/lib/tsan/rtl/tsan_interface_inl.h projects/clang400-import/contrib/compiler-rt/lib/tsan/rtl/tsan_interface_java.cc projects/clang400-import/contrib/compiler-rt/lib/tsan/rtl/tsan_interface_java.h projects/clang400-import/contrib/compiler-rt/lib/tsan/rtl/tsan_libdispatch_mac.cc projects/clang400-import/contrib/compiler-rt/lib/tsan/rtl/tsan_mman.cc projects/clang400-import/contrib/compiler-rt/lib/tsan/rtl/tsan_mutexset.h projects/clang400-import/contrib/compiler-rt/lib/tsan/rtl/tsan_platform.h projects/clang400-import/contrib/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc projects/clang400-import/contrib/compiler-rt/lib/tsan/rtl/tsan_platform_mac.cc projects/clang400-import/contrib/compiler-rt/lib/tsan/rtl/tsan_platform_posix.cc projects/clang400-import/contrib/compiler-rt/lib/tsan/rtl/tsan_platform_windows.cc projects/clang400-import/contrib/compiler-rt/lib/tsan/rtl/tsan_report.cc projects/clang400-import/contrib/compiler-rt/lib/tsan/rtl/tsan_rtl.cc projects/clang400-import/contrib/compiler-rt/lib/tsan/rtl/tsan_rtl.h projects/clang400-import/contrib/compiler-rt/lib/tsan/rtl/tsan_rtl_aarch64.S projects/clang400-import/contrib/compiler-rt/lib/tsan/rtl/tsan_rtl_mutex.cc projects/clang400-import/contrib/compiler-rt/lib/tsan/rtl/tsan_rtl_proc.cc projects/clang400-import/contrib/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cc projects/clang400-import/contrib/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cc projects/clang400-import/contrib/compiler-rt/lib/tsan/rtl/tsan_suppressions.cc projects/clang400-import/contrib/compiler-rt/lib/tsan/rtl/tsan_sync.cc projects/clang400-import/contrib/compiler-rt/lib/tsan/rtl/tsan_sync.h projects/clang400-import/contrib/compiler-rt/lib/tsan/rtl/tsan_trace.h projects/clang400-import/contrib/compiler-rt/lib/ubsan/ubsan_handlers.cc projects/clang400-import/contrib/compiler-rt/lib/ubsan/ubsan_handlers.h projects/clang400-import/contrib/compiler-rt/lib/ubsan/ubsan_init.cc projects/clang400-import/contrib/compiler-rt/lib/ubsan/ubsan_type_hash_itanium.cc Directory Properties: projects/clang400-import/contrib/compiler-rt/ (props changed) Modified: projects/clang400-import/contrib/compiler-rt/include/sanitizer/common_interface_defs.h ============================================================================== --- projects/clang400-import/contrib/compiler-rt/include/sanitizer/common_interface_defs.h Sun Jan 8 19:39:03 2017 (r311696) +++ projects/clang400-import/contrib/compiler-rt/include/sanitizer/common_interface_defs.h Sun Jan 8 19:47:17 2017 (r311697) @@ -117,6 +117,16 @@ extern "C" { // Print the stack trace leading to this call. Useful for debugging user code. void __sanitizer_print_stack_trace(); + // Symbolizes the supplied 'pc' using the format string 'fmt'. + // Outputs at most 'out_buf_size' bytes into 'out_buf'. + // The format syntax is described in + // lib/sanitizer_common/sanitizer_stacktrace_printer.h. + void __sanitizer_symbolize_pc(void *pc, const char *fmt, char *out_buf, + size_t out_buf_size); + // Same as __sanitizer_symbolize_pc, but for data section (i.e. globals). + void __sanitizer_symbolize_global(void *data_ptr, const char *fmt, + char *out_buf, size_t out_buf_size); + // Sets the callback to be called right before death on error. // Passing 0 will unset the callback. void __sanitizer_set_death_callback(void (*callback)(void)); @@ -169,7 +179,16 @@ extern "C" { // use-after-return detection. void __sanitizer_start_switch_fiber(void **fake_stack_save, const void *bottom, size_t size); - void __sanitizer_finish_switch_fiber(void *fake_stack_save); + void __sanitizer_finish_switch_fiber(void *fake_stack_save, + const void **bottom_old, + size_t *size_old); + + // Get full module name and calculate pc offset within it. + // Returns 1 if pc belongs to some module, 0 if module was not found. + int __sanitizer_get_module_and_offset_for_pc(void *pc, char *module_path, + size_t module_path_len, + void **pc_offset); + #ifdef __cplusplus } // extern "C" #endif Modified: projects/clang400-import/contrib/compiler-rt/include/sanitizer/coverage_interface.h ============================================================================== --- projects/clang400-import/contrib/compiler-rt/include/sanitizer/coverage_interface.h Sun Jan 8 19:39:03 2017 (r311696) +++ projects/clang400-import/contrib/compiler-rt/include/sanitizer/coverage_interface.h Sun Jan 8 19:47:17 2017 (r311697) @@ -23,6 +23,11 @@ extern "C" { void __sanitizer_cov_init(); // Record and dump coverage info. void __sanitizer_cov_dump(); + + // Dump collected coverage info. Sorts pcs by module into individual + // .sancov files. + void __sanitizer_dump_coverage(const uintptr_t *pcs, uintptr_t len); + // Open <name>.sancov.packed in the coverage directory and return the file // descriptor. Returns -1 on failure, or if coverage dumping is disabled. // This is intended for use by sandboxing code. @@ -41,13 +46,6 @@ extern "C" { // Some of the entries in *data will be zero. uintptr_t __sanitizer_get_coverage_guards(uintptr_t **data); - // Set *data to the growing buffer with covered PCs and return the size - // of the buffer. The entries are never zero. - // When only unique pcs are collected, the size is equal to - // __sanitizer_get_total_unique_coverage. - // WARNING: EXPERIMENTAL API. - uintptr_t __sanitizer_get_coverage_pc_buffer(uintptr_t **data); - // The coverage instrumentation may optionally provide imprecise counters. // Rather than exposing the counter values to the user we instead map // the counters to a bitset. @@ -65,6 +63,7 @@ extern "C" { // __sanitizer_get_number_of_counters bytes long and 8-aligned. uintptr_t __sanitizer_update_counter_bitset_and_clear_counters(uint8_t *bitset); + #ifdef __cplusplus } // extern "C" #endif Modified: projects/clang400-import/contrib/compiler-rt/lib/asan/asan_activation.cc ============================================================================== --- projects/clang400-import/contrib/compiler-rt/lib/asan/asan_activation.cc Sun Jan 8 19:39:03 2017 (r311696) +++ projects/clang400-import/contrib/compiler-rt/lib/asan/asan_activation.cc Sun Jan 8 19:47:17 2017 (r311697) @@ -79,11 +79,13 @@ static struct AsanDeactivatedFlags { Report( "quarantine_size_mb %d, max_redzone %d, poison_heap %d, " "malloc_context_size %d, alloc_dealloc_mismatch %d, " - "allocator_may_return_null %d, coverage %d, coverage_dir %s\n", + "allocator_may_return_null %d, coverage %d, coverage_dir %s, " + "allocator_release_to_os_interval_ms %d\n", allocator_options.quarantine_size_mb, allocator_options.max_redzone, poison_heap, malloc_context_size, allocator_options.alloc_dealloc_mismatch, - allocator_options.may_return_null, coverage, coverage_dir); + allocator_options.may_return_null, coverage, coverage_dir, + allocator_options.release_to_os_interval_ms); } } asan_deactivated_flags; Modified: projects/clang400-import/contrib/compiler-rt/lib/asan/asan_activation_flags.inc ============================================================================== --- projects/clang400-import/contrib/compiler-rt/lib/asan/asan_activation_flags.inc Sun Jan 8 19:39:03 2017 (r311696) +++ projects/clang400-import/contrib/compiler-rt/lib/asan/asan_activation_flags.inc Sun Jan 8 19:47:17 2017 (r311697) @@ -33,3 +33,4 @@ COMMON_ACTIVATION_FLAG(bool, coverage) COMMON_ACTIVATION_FLAG(const char *, coverage_dir) COMMON_ACTIVATION_FLAG(int, verbosity) COMMON_ACTIVATION_FLAG(bool, help) +COMMON_ACTIVATION_FLAG(s32, allocator_release_to_os_interval_ms) Modified: projects/clang400-import/contrib/compiler-rt/lib/asan/asan_allocator.cc ============================================================================== --- projects/clang400-import/contrib/compiler-rt/lib/asan/asan_allocator.cc Sun Jan 8 19:39:03 2017 (r311696) +++ projects/clang400-import/contrib/compiler-rt/lib/asan/asan_allocator.cc Sun Jan 8 19:47:17 2017 (r311697) @@ -207,25 +207,27 @@ QuarantineCache *GetQuarantineCache(Asan void AllocatorOptions::SetFrom(const Flags *f, const CommonFlags *cf) { quarantine_size_mb = f->quarantine_size_mb; + thread_local_quarantine_size_kb = f->thread_local_quarantine_size_kb; min_redzone = f->redzone; max_redzone = f->max_redzone; may_return_null = cf->allocator_may_return_null; alloc_dealloc_mismatch = f->alloc_dealloc_mismatch; + release_to_os_interval_ms = cf->allocator_release_to_os_interval_ms; } void AllocatorOptions::CopyTo(Flags *f, CommonFlags *cf) { f->quarantine_size_mb = quarantine_size_mb; + f->thread_local_quarantine_size_kb = thread_local_quarantine_size_kb; f->redzone = min_redzone; f->max_redzone = max_redzone; cf->allocator_may_return_null = may_return_null; f->alloc_dealloc_mismatch = alloc_dealloc_mismatch; + cf->allocator_release_to_os_interval_ms = release_to_os_interval_ms; } struct Allocator { static const uptr kMaxAllowedMallocSize = FIRST_32_SECOND_64(3UL << 30, 1ULL << 40); - static const uptr kMaxThreadLocalQuarantine = - FIRST_32_SECOND_64(1 << 18, 1 << 20); AsanAllocator allocator; AsanQuarantine quarantine; @@ -254,7 +256,7 @@ struct Allocator { void SharedInitCode(const AllocatorOptions &options) { CheckOptions(options); quarantine.Init((uptr)options.quarantine_size_mb << 20, - kMaxThreadLocalQuarantine); + (uptr)options.thread_local_quarantine_size_kb << 10); atomic_store(&alloc_dealloc_mismatch, options.alloc_dealloc_mismatch, memory_order_release); atomic_store(&min_redzone, options.min_redzone, memory_order_release); @@ -262,22 +264,59 @@ struct Allocator { } void Initialize(const AllocatorOptions &options) { - allocator.Init(options.may_return_null); + allocator.Init(options.may_return_null, options.release_to_os_interval_ms); SharedInitCode(options); } + void RePoisonChunk(uptr chunk) { + // This could a user-facing chunk (with redzones), or some internal + // housekeeping chunk, like TransferBatch. Start by assuming the former. + AsanChunk *ac = GetAsanChunk((void *)chunk); + uptr allocated_size = allocator.GetActuallyAllocatedSize((void *)ac); + uptr beg = ac->Beg(); + uptr end = ac->Beg() + ac->UsedSize(true); + uptr chunk_end = chunk + allocated_size; + if (chunk < beg && beg < end && end <= chunk_end) { + // Looks like a valid AsanChunk. Or maybe not. Be conservative and only + // poison the redzones. + PoisonShadow(chunk, beg - chunk, kAsanHeapLeftRedzoneMagic); + uptr end_aligned_down = RoundDownTo(end, SHADOW_GRANULARITY); + FastPoisonShadowPartialRightRedzone( + end_aligned_down, end - end_aligned_down, + chunk_end - end_aligned_down, kAsanHeapLeftRedzoneMagic); + } else { + // This can not be an AsanChunk. Poison everything. It may be reused as + // AsanChunk later. + PoisonShadow(chunk, allocated_size, kAsanHeapLeftRedzoneMagic); + } + } + void ReInitialize(const AllocatorOptions &options) { allocator.SetMayReturnNull(options.may_return_null); + allocator.SetReleaseToOSIntervalMs(options.release_to_os_interval_ms); SharedInitCode(options); + + // Poison all existing allocation's redzones. + if (CanPoisonMemory()) { + allocator.ForceLock(); + allocator.ForEachChunk( + [](uptr chunk, void *alloc) { + ((Allocator *)alloc)->RePoisonChunk(chunk); + }, + this); + allocator.ForceUnlock(); + } } void GetOptions(AllocatorOptions *options) const { options->quarantine_size_mb = quarantine.GetSize() >> 20; + options->thread_local_quarantine_size_kb = quarantine.GetCacheSize() >> 10; options->min_redzone = atomic_load(&min_redzone, memory_order_acquire); options->max_redzone = atomic_load(&max_redzone, memory_order_acquire); options->may_return_null = allocator.MayReturnNull(); options->alloc_dealloc_mismatch = atomic_load(&alloc_dealloc_mismatch, memory_order_acquire); + options->release_to_os_interval_ms = allocator.ReleaseToOSIntervalMs(); } // -------------------- Helper methods. ------------------------- @@ -356,7 +395,7 @@ struct Allocator { if (size > kMaxAllowedMallocSize || needed_size > kMaxAllowedMallocSize) { Report("WARNING: AddressSanitizer failed to allocate 0x%zx bytes\n", (void*)size); - return allocator.ReturnNullOrDie(); + return allocator.ReturnNullOrDieOnBadRequest(); } AsanThread *t = GetCurrentThread(); @@ -373,8 +412,7 @@ struct Allocator { allocator.Allocate(cache, needed_size, 8, false, check_rss_limit); } - if (!allocated) - return allocator.ReturnNullOrDie(); + if (!allocated) return allocator.ReturnNullOrDieOnOOM(); if (*(u8 *)MEM_TO_SHADOW((uptr)allocated) == 0 && CanPoisonMemory()) { // Heap poisoning is enabled, but the allocator provides an unpoisoned @@ -530,7 +568,7 @@ struct Allocator { if (delete_size && flags()->new_delete_type_mismatch && delete_size != m->UsedSize()) { - ReportNewDeleteSizeMismatch(p, m->UsedSize(), delete_size, stack); + ReportNewDeleteSizeMismatch(p, delete_size, stack); } QuarantineChunk(m, ptr, stack, alloc_type); @@ -563,7 +601,7 @@ struct Allocator { void *Calloc(uptr nmemb, uptr size, BufferedStackTrace *stack) { if (CallocShouldReturnNullDueToOverflow(size, nmemb)) - return allocator.ReturnNullOrDie(); + return allocator.ReturnNullOrDieOnBadRequest(); void *ptr = Allocate(nmemb * size, 8, stack, FROM_MALLOC, false); // If the memory comes from the secondary allocator no need to clear it // as it comes directly from mmap. @@ -643,6 +681,7 @@ struct Allocator { void PrintStats() { allocator.PrintStats(); + quarantine.PrintStats(); } void ForceLock() { @@ -662,17 +701,23 @@ static AsanAllocator &get_allocator() { return instance.allocator; } -bool AsanChunkView::IsValid() { +bool AsanChunkView::IsValid() const { return chunk_ && chunk_->chunk_state != CHUNK_AVAILABLE; } -bool AsanChunkView::IsAllocated() { +bool AsanChunkView::IsAllocated() const { return chunk_ && chunk_->chunk_state == CHUNK_ALLOCATED; } -uptr AsanChunkView::Beg() { return chunk_->Beg(); } -uptr AsanChunkView::End() { return Beg() + UsedSize(); } -uptr AsanChunkView::UsedSize() { return chunk_->UsedSize(); } -uptr AsanChunkView::AllocTid() { return chunk_->alloc_tid; } -uptr AsanChunkView::FreeTid() { return chunk_->free_tid; } +bool AsanChunkView::IsQuarantined() const { + return chunk_ && chunk_->chunk_state == CHUNK_QUARANTINE; +} +uptr AsanChunkView::Beg() const { return chunk_->Beg(); } +uptr AsanChunkView::End() const { return Beg() + UsedSize(); } +uptr AsanChunkView::UsedSize() const { return chunk_->UsedSize(); } +uptr AsanChunkView::AllocTid() const { return chunk_->alloc_tid; } +uptr AsanChunkView::FreeTid() const { return chunk_->free_tid; } +AllocType AsanChunkView::GetAllocType() const { + return (AllocType)chunk_->alloc_type; +} static StackTrace GetStackTraceFromId(u32 id) { CHECK(id); @@ -681,14 +726,14 @@ static StackTrace GetStackTraceFromId(u3 return res; } -u32 AsanChunkView::GetAllocStackId() { return chunk_->alloc_context_id; } -u32 AsanChunkView::GetFreeStackId() { return chunk_->free_context_id; } +u32 AsanChunkView::GetAllocStackId() const { return chunk_->alloc_context_id; } +u32 AsanChunkView::GetFreeStackId() const { return chunk_->free_context_id; } -StackTrace AsanChunkView::GetAllocStack() { +StackTrace AsanChunkView::GetAllocStack() const { return GetStackTraceFromId(GetAllocStackId()); } -StackTrace AsanChunkView::GetFreeStack() { +StackTrace AsanChunkView::GetFreeStack() const { return GetStackTraceFromId(GetFreeStackId()); } @@ -707,6 +752,9 @@ void GetAllocatorOptions(AllocatorOption AsanChunkView FindHeapChunkByAddress(uptr addr) { return instance.FindHeapChunkByAddress(addr); } +AsanChunkView FindHeapChunkByAllocBeg(uptr addr) { + return AsanChunkView(instance.GetAsanChunk(reinterpret_cast<void*>(addr))); +} void AsanThreadLocalMallocStorage::CommitBack() { instance.CommitBack(this); Modified: projects/clang400-import/contrib/compiler-rt/lib/asan/asan_allocator.h ============================================================================== --- projects/clang400-import/contrib/compiler-rt/lib/asan/asan_allocator.h Sun Jan 8 19:39:03 2017 (r311696) +++ projects/clang400-import/contrib/compiler-rt/lib/asan/asan_allocator.h Sun Jan 8 19:47:17 2017 (r311697) @@ -33,10 +33,12 @@ struct AsanChunk; struct AllocatorOptions { u32 quarantine_size_mb; + u32 thread_local_quarantine_size_kb; u16 min_redzone; u16 max_redzone; u8 may_return_null; u8 alloc_dealloc_mismatch; + s32 release_to_os_interval_ms; void SetFrom(const Flags *f, const CommonFlags *cf); void CopyTo(Flags *f, CommonFlags *cf); @@ -49,27 +51,29 @@ void GetAllocatorOptions(AllocatorOption class AsanChunkView { public: explicit AsanChunkView(AsanChunk *chunk) : chunk_(chunk) {} - bool IsValid(); // Checks if AsanChunkView points to a valid allocated - // or quarantined chunk. - bool IsAllocated(); // Checks if the memory is currently allocated. - uptr Beg(); // First byte of user memory. - uptr End(); // Last byte of user memory. - uptr UsedSize(); // Size requested by the user. - uptr AllocTid(); - uptr FreeTid(); + bool IsValid() const; // Checks if AsanChunkView points to a valid + // allocated or quarantined chunk. + bool IsAllocated() const; // Checks if the memory is currently allocated. + bool IsQuarantined() const; // Checks if the memory is currently quarantined. + uptr Beg() const; // First byte of user memory. + uptr End() const; // Last byte of user memory. + uptr UsedSize() const; // Size requested by the user. + uptr AllocTid() const; + uptr FreeTid() const; bool Eq(const AsanChunkView &c) const { return chunk_ == c.chunk_; } - u32 GetAllocStackId(); - u32 GetFreeStackId(); - StackTrace GetAllocStack(); - StackTrace GetFreeStack(); - bool AddrIsInside(uptr addr, uptr access_size, sptr *offset) { + u32 GetAllocStackId() const; + u32 GetFreeStackId() const; + StackTrace GetAllocStack() const; + StackTrace GetFreeStack() const; + AllocType GetAllocType() const; + bool AddrIsInside(uptr addr, uptr access_size, sptr *offset) const { if (addr >= Beg() && (addr + access_size) <= End()) { *offset = addr - Beg(); return true; } return false; } - bool AddrIsAtLeft(uptr addr, uptr access_size, sptr *offset) { + bool AddrIsAtLeft(uptr addr, uptr access_size, sptr *offset) const { (void)access_size; if (addr < Beg()) { *offset = Beg() - addr; @@ -77,7 +81,7 @@ class AsanChunkView { } return false; } - bool AddrIsAtRight(uptr addr, uptr access_size, sptr *offset) { + bool AddrIsAtRight(uptr addr, uptr access_size, sptr *offset) const { if (addr + access_size > End()) { *offset = addr - End(); return true; @@ -90,6 +94,7 @@ class AsanChunkView { }; AsanChunkView FindHeapChunkByAddress(uptr address); +AsanChunkView FindHeapChunkByAllocBeg(uptr address); // List of AsanChunks with total size. class AsanChunkFifoList: public IntrusiveList<AsanChunk> { @@ -117,18 +122,36 @@ struct AsanMapUnmapCallback { # if defined(__powerpc64__) const uptr kAllocatorSpace = 0xa0000000000ULL; const uptr kAllocatorSize = 0x20000000000ULL; // 2T. +typedef DefaultSizeClassMap SizeClassMap; +# elif defined(__aarch64__) && SANITIZER_ANDROID +const uptr kAllocatorSpace = 0x3000000000ULL; +const uptr kAllocatorSize = 0x2000000000ULL; // 128G. +typedef VeryCompactSizeClassMap SizeClassMap; # elif defined(__aarch64__) -// AArch64/SANITIZIER_CAN_USER_ALLOCATOR64 is only for 42-bit VMA +// AArch64/SANITIZER_CAN_USER_ALLOCATOR64 is only for 42-bit VMA // so no need to different values for different VMA. const uptr kAllocatorSpace = 0x10000000000ULL; const uptr kAllocatorSize = 0x10000000000ULL; // 3T. +typedef DefaultSizeClassMap SizeClassMap; +# elif SANITIZER_WINDOWS +const uptr kAllocatorSpace = ~(uptr)0; +const uptr kAllocatorSize = 0x8000000000ULL; // 500G +typedef DefaultSizeClassMap SizeClassMap; # else const uptr kAllocatorSpace = 0x600000000000ULL; const uptr kAllocatorSize = 0x40000000000ULL; // 4T. -# endif typedef DefaultSizeClassMap SizeClassMap; -typedef SizeClassAllocator64<kAllocatorSpace, kAllocatorSize, 0 /*metadata*/, - SizeClassMap, AsanMapUnmapCallback> PrimaryAllocator; +# endif +struct AP64 { // Allocator64 parameters. Deliberately using a short name. + static const uptr kSpaceBeg = kAllocatorSpace; + static const uptr kSpaceSize = kAllocatorSize; + static const uptr kMetadataSize = 0; + typedef __asan::SizeClassMap SizeClassMap; + typedef AsanMapUnmapCallback MapUnmapCallback; + static const uptr kFlags = 0; +}; + +typedef SizeClassAllocator64<AP64> PrimaryAllocator; #else // Fallback to SizeClassAllocator32. static const uptr kRegionSizeLog = 20; static const uptr kNumRegions = SANITIZER_MMAP_RANGE_SIZE >> kRegionSizeLog; Modified: projects/clang400-import/contrib/compiler-rt/lib/asan/asan_debugging.cc ============================================================================== --- projects/clang400-import/contrib/compiler-rt/lib/asan/asan_debugging.cc Sun Jan 8 19:39:03 2017 (r311696) +++ projects/clang400-import/contrib/compiler-rt/lib/asan/asan_debugging.cc Sun Jan 8 19:47:17 2017 (r311697) @@ -14,74 +14,39 @@ //===----------------------------------------------------------------------===// #include "asan_allocator.h" +#include "asan_descriptions.h" #include "asan_flags.h" #include "asan_internal.h" #include "asan_mapping.h" #include "asan_report.h" #include "asan_thread.h" -namespace __asan { - -void GetInfoForStackVar(uptr addr, AddressDescription *descr, AsanThread *t) { - descr->name[0] = 0; - descr->region_address = 0; - descr->region_size = 0; - descr->region_kind = "stack"; +namespace { +using namespace __asan; - AsanThread::StackFrameAccess access; - if (!t->GetStackFrameAccessByAddr(addr, &access)) - return; +static void FindInfoForStackVar(uptr addr, const char *frame_descr, uptr offset, + char *name, uptr name_size, + uptr ®ion_address, uptr ®ion_size) { InternalMmapVector<StackVarDescr> vars(16); - if (!ParseFrameDescription(access.frame_descr, &vars)) { + if (!ParseFrameDescription(frame_descr, &vars)) { return; } for (uptr i = 0; i < vars.size(); i++) { - if (access.offset <= vars[i].beg + vars[i].size) { - internal_strncat(descr->name, vars[i].name_pos, - Min(descr->name_size, vars[i].name_len)); - descr->region_address = addr - (access.offset - vars[i].beg); - descr->region_size = vars[i].size; + if (offset <= vars[i].beg + vars[i].size) { + // We use name_len + 1 because strlcpy will guarantee a \0 at the end, so + // if we're limiting the copy due to name_len, we add 1 to ensure we copy + // the whole name and then terminate with '\0'. + internal_strlcpy(name, vars[i].name_pos, + Min(name_size, vars[i].name_len + 1)); + region_address = addr - (offset - vars[i].beg); + region_size = vars[i].size; return; } } } -void GetInfoForHeapAddress(uptr addr, AddressDescription *descr) { - AsanChunkView chunk = FindHeapChunkByAddress(addr); - - descr->name[0] = 0; - descr->region_address = 0; - descr->region_size = 0; - - if (!chunk.IsValid()) { - descr->region_kind = "heap-invalid"; - return; - } - - descr->region_address = chunk.Beg(); - descr->region_size = chunk.UsedSize(); - descr->region_kind = "heap"; -} - -void AsanLocateAddress(uptr addr, AddressDescription *descr) { - if (DescribeAddressIfShadow(addr, descr, /* print */ false)) { - return; - } - if (GetInfoForAddressIfGlobal(addr, descr)) { - return; - } - asanThreadRegistry().Lock(); - AsanThread *thread = FindThreadByStackAddress(addr); - asanThreadRegistry().Unlock(); - if (thread) { - GetInfoForStackVar(addr, descr, thread); - return; - } - GetInfoForHeapAddress(addr, descr); -} - -static uptr AsanGetStack(uptr addr, uptr *trace, u32 size, u32 *thread_id, +uptr AsanGetStack(uptr addr, uptr *trace, u32 size, u32 *thread_id, bool alloc_stack) { AsanChunkView chunk = FindHeapChunkByAddress(addr); if (!chunk.IsValid()) return 0; @@ -108,18 +73,58 @@ static uptr AsanGetStack(uptr addr, uptr return 0; } -} // namespace __asan - -using namespace __asan; +} // namespace SANITIZER_INTERFACE_ATTRIBUTE const char *__asan_locate_address(uptr addr, char *name, uptr name_size, - uptr *region_address, uptr *region_size) { - AddressDescription descr = { name, name_size, 0, 0, nullptr }; - AsanLocateAddress(addr, &descr); - if (region_address) *region_address = descr.region_address; - if (region_size) *region_size = descr.region_size; - return descr.region_kind; + uptr *region_address_ptr, + uptr *region_size_ptr) { + AddressDescription descr(addr); + uptr region_address = 0; + uptr region_size = 0; + const char *region_kind = nullptr; + if (name && name_size > 0) name[0] = 0; + + if (auto shadow = descr.AsShadow()) { + // region_{address,size} are already 0 + switch (shadow->kind) { + case kShadowKindLow: + region_kind = "low shadow"; + break; + case kShadowKindGap: + region_kind = "shadow gap"; + break; + case kShadowKindHigh: + region_kind = "high shadow"; + break; + } + } else if (auto heap = descr.AsHeap()) { + region_kind = "heap"; + region_address = heap->chunk_access.chunk_begin; + region_size = heap->chunk_access.chunk_size; + } else if (auto stack = descr.AsStack()) { + region_kind = "stack"; + if (!stack->frame_descr) { + // region_{address,size} are already 0 + } else { + FindInfoForStackVar(addr, stack->frame_descr, stack->offset, name, + name_size, region_address, region_size); + } + } else if (auto global = descr.AsGlobal()) { + region_kind = "global"; + auto &g = global->globals[0]; + internal_strlcpy(name, g.name, name_size); + region_address = g.beg; + region_size = g.size; + } else { + // region_{address,size} are already 0 + region_kind = "heap-invalid"; + } + + CHECK(region_kind); + if (region_address_ptr) *region_address_ptr = region_address; + if (region_size_ptr) *region_size_ptr = region_size; + return region_kind; } SANITIZER_INTERFACE_ATTRIBUTE Copied: projects/clang400-import/contrib/compiler-rt/lib/asan/asan_descriptions.cc (from r311696, vendor/compiler-rt/dist/lib/asan/asan_descriptions.cc) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/clang400-import/contrib/compiler-rt/lib/asan/asan_descriptions.cc Sun Jan 8 19:47:17 2017 (r311697, copy of r311696, vendor/compiler-rt/dist/lib/asan/asan_descriptions.cc) @@ -0,0 +1,486 @@ +//===-- asan_descriptions.cc ------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file is a part of AddressSanitizer, an address sanity checker. +// +// ASan functions for getting information about an address and/or printing it. +//===----------------------------------------------------------------------===// + +#include "asan_descriptions.h" +#include "asan_mapping.h" +#include "asan_report.h" +#include "asan_stack.h" +#include "sanitizer_common/sanitizer_stackdepot.h" + +namespace __asan { + +// Return " (thread_name) " or an empty string if the name is empty. +const char *ThreadNameWithParenthesis(AsanThreadContext *t, char buff[], + uptr buff_len) { + const char *name = t->name; + if (name[0] == '\0') return ""; + buff[0] = 0; + internal_strncat(buff, " (", 3); + internal_strncat(buff, name, buff_len - 4); + internal_strncat(buff, ")", 2); + return buff; +} + +const char *ThreadNameWithParenthesis(u32 tid, char buff[], uptr buff_len) { + if (tid == kInvalidTid) return ""; + asanThreadRegistry().CheckLocked(); + AsanThreadContext *t = GetThreadContextByTidLocked(tid); + return ThreadNameWithParenthesis(t, buff, buff_len); +} + +void DescribeThread(AsanThreadContext *context) { + CHECK(context); + asanThreadRegistry().CheckLocked(); + // No need to announce the main thread. + if (context->tid == 0 || context->announced) { + return; + } + context->announced = true; + char tname[128]; + InternalScopedString str(1024); + str.append("Thread T%d%s", context->tid, + ThreadNameWithParenthesis(context->tid, tname, sizeof(tname))); + if (context->parent_tid == kInvalidTid) { + str.append(" created by unknown thread\n"); + Printf("%s", str.data()); + return; + } + str.append( + " created by T%d%s here:\n", context->parent_tid, + ThreadNameWithParenthesis(context->parent_tid, tname, sizeof(tname))); + Printf("%s", str.data()); + StackDepotGet(context->stack_id).Print(); + // Recursively described parent thread if needed. + if (flags()->print_full_thread_history) { + AsanThreadContext *parent_context = + GetThreadContextByTidLocked(context->parent_tid); + DescribeThread(parent_context); + } +} + +// Shadow descriptions +static bool GetShadowKind(uptr addr, ShadowKind *shadow_kind) { + CHECK(!AddrIsInMem(addr)); + if (AddrIsInShadowGap(addr)) { + *shadow_kind = kShadowKindGap; + } else if (AddrIsInHighShadow(addr)) { + *shadow_kind = kShadowKindHigh; + } else if (AddrIsInLowShadow(addr)) { + *shadow_kind = kShadowKindLow; + } else { + CHECK(0 && "Address is not in memory and not in shadow?"); + return false; + } + return true; +} + +bool DescribeAddressIfShadow(uptr addr) { + ShadowAddressDescription descr; + if (!GetShadowAddressInformation(addr, &descr)) return false; + descr.Print(); + return true; +} + +bool GetShadowAddressInformation(uptr addr, ShadowAddressDescription *descr) { + if (AddrIsInMem(addr)) return false; + ShadowKind shadow_kind; + if (!GetShadowKind(addr, &shadow_kind)) return false; + if (shadow_kind != kShadowKindGap) descr->shadow_byte = *(u8 *)addr; + descr->addr = addr; + descr->kind = shadow_kind; + return true; +} + +// Heap descriptions +static void GetAccessToHeapChunkInformation(ChunkAccess *descr, + AsanChunkView chunk, uptr addr, + uptr access_size) { + descr->bad_addr = addr; + if (chunk.AddrIsAtLeft(addr, access_size, &descr->offset)) { + descr->access_type = kAccessTypeLeft; + } else if (chunk.AddrIsAtRight(addr, access_size, &descr->offset)) { + descr->access_type = kAccessTypeRight; + if (descr->offset < 0) { + descr->bad_addr -= descr->offset; + descr->offset = 0; + } + } else if (chunk.AddrIsInside(addr, access_size, &descr->offset)) { + descr->access_type = kAccessTypeInside; + } else { + descr->access_type = kAccessTypeUnknown; + } + descr->chunk_begin = chunk.Beg(); + descr->chunk_size = chunk.UsedSize(); + descr->alloc_type = chunk.GetAllocType(); +} + +static void PrintHeapChunkAccess(uptr addr, const ChunkAccess &descr) { + Decorator d; + InternalScopedString str(4096); + str.append("%s", d.Location()); + switch (descr.access_type) { + case kAccessTypeLeft: + str.append("%p is located %zd bytes to the left of", + (void *)descr.bad_addr, descr.offset); + break; + case kAccessTypeRight: + str.append("%p is located %zd bytes to the right of", + (void *)descr.bad_addr, descr.offset); + break; + case kAccessTypeInside: + str.append("%p is located %zd bytes inside of", (void *)descr.bad_addr, + descr.offset); + break; + case kAccessTypeUnknown: + str.append( + "%p is located somewhere around (this is AddressSanitizer bug!)", + (void *)descr.bad_addr); + } + str.append(" %zu-byte region [%p,%p)\n", descr.chunk_size, + (void *)descr.chunk_begin, + (void *)(descr.chunk_begin + descr.chunk_size)); + str.append("%s", d.EndLocation()); + Printf("%s", str.data()); +} + +bool GetHeapAddressInformation(uptr addr, uptr access_size, + HeapAddressDescription *descr) { + AsanChunkView chunk = FindHeapChunkByAddress(addr); + if (!chunk.IsValid()) { + return false; + } + descr->addr = addr; + GetAccessToHeapChunkInformation(&descr->chunk_access, chunk, addr, + access_size); + CHECK_NE(chunk.AllocTid(), kInvalidTid); + descr->alloc_tid = chunk.AllocTid(); + descr->alloc_stack_id = chunk.GetAllocStackId(); + descr->free_tid = chunk.FreeTid(); + if (descr->free_tid != kInvalidTid) + descr->free_stack_id = chunk.GetFreeStackId(); + return true; +} + +static StackTrace GetStackTraceFromId(u32 id) { + CHECK(id); + StackTrace res = StackDepotGet(id); + CHECK(res.trace); + return res; +} + +bool DescribeAddressIfHeap(uptr addr, uptr access_size) { + HeapAddressDescription descr; + if (!GetHeapAddressInformation(addr, access_size, &descr)) { + Printf( + "AddressSanitizer can not describe address in more detail " + "(wild memory access suspected).\n"); + return false; + } + descr.Print(); + return true; +} + +// Stack descriptions +bool GetStackAddressInformation(uptr addr, uptr access_size, + StackAddressDescription *descr) { + AsanThread *t = FindThreadByStackAddress(addr); + if (!t) return false; + + descr->addr = addr; + descr->tid = t->tid(); + // Try to fetch precise stack frame for this access. + AsanThread::StackFrameAccess access; + if (!t->GetStackFrameAccessByAddr(addr, &access)) { + descr->frame_descr = nullptr; + return true; + } + + descr->offset = access.offset; + descr->access_size = access_size; + descr->frame_pc = access.frame_pc; + descr->frame_descr = access.frame_descr; + +#if SANITIZER_PPC64V1 + // On PowerPC64 ELFv1, the address of a function actually points to a + // three-doubleword data structure with the first field containing + // the address of the function's code. + descr->frame_pc = *reinterpret_cast<uptr *>(descr->frame_pc); +#endif + descr->frame_pc += 16; + + return true; +} + +static void PrintAccessAndVarIntersection(const StackVarDescr &var, uptr addr, + uptr access_size, uptr prev_var_end, + uptr next_var_beg) { + uptr var_end = var.beg + var.size; + uptr addr_end = addr + access_size; + const char *pos_descr = nullptr; + // If the variable [var.beg, var_end) is the nearest variable to the + // current memory access, indicate it in the log. + if (addr >= var.beg) { + if (addr_end <= var_end) + pos_descr = "is inside"; // May happen if this is a use-after-return. + else if (addr < var_end) + pos_descr = "partially overflows"; + else if (addr_end <= next_var_beg && + next_var_beg - addr_end >= addr - var_end) + pos_descr = "overflows"; + } else { + if (addr_end > var.beg) + pos_descr = "partially underflows"; + else if (addr >= prev_var_end && addr - prev_var_end >= var.beg - addr_end) + pos_descr = "underflows"; + } + InternalScopedString str(1024); + str.append(" [%zd, %zd)", var.beg, var_end); + // Render variable name. + str.append(" '"); + for (uptr i = 0; i < var.name_len; ++i) { + str.append("%c", var.name_pos[i]); + } + str.append("'"); + if (pos_descr) { + Decorator d; + // FIXME: we may want to also print the size of the access here, + // but in case of accesses generated by memset it may be confusing. + str.append("%s <== Memory access at offset %zd %s this variable%s\n", + d.Location(), addr, pos_descr, d.EndLocation()); + } else { + str.append("\n"); + } + Printf("%s", str.data()); +} + +bool DescribeAddressIfStack(uptr addr, uptr access_size) { + StackAddressDescription descr; + if (!GetStackAddressInformation(addr, access_size, &descr)) return false; + descr.Print(); + return true; +} + +// Global descriptions +static void DescribeAddressRelativeToGlobal(uptr addr, uptr access_size, + const __asan_global &g) { + InternalScopedString str(4096); + Decorator d; + str.append("%s", d.Location()); + if (addr < g.beg) { + str.append("%p is located %zd bytes to the left", (void *)addr, + g.beg - addr); + } else if (addr + access_size > g.beg + g.size) { + if (addr < g.beg + g.size) addr = g.beg + g.size; + str.append("%p is located %zd bytes to the right", (void *)addr, + addr - (g.beg + g.size)); + } else { + // Can it happen? + str.append("%p is located %zd bytes inside", (void *)addr, addr - g.beg); + } + str.append(" of global variable '%s' defined in '", + MaybeDemangleGlobalName(g.name)); + PrintGlobalLocation(&str, g); + str.append("' (0x%zx) of size %zu\n", g.beg, g.size); + str.append("%s", d.EndLocation()); + PrintGlobalNameIfASCII(&str, g); + Printf("%s", str.data()); +} + +bool GetGlobalAddressInformation(uptr addr, uptr access_size, + GlobalAddressDescription *descr) { + descr->addr = addr; + int globals_num = GetGlobalsForAddress(addr, descr->globals, descr->reg_sites, + ARRAY_SIZE(descr->globals)); + descr->size = globals_num; + descr->access_size = access_size; + return globals_num != 0; +} + +bool DescribeAddressIfGlobal(uptr addr, uptr access_size, + const char *bug_type) { + GlobalAddressDescription descr; + if (!GetGlobalAddressInformation(addr, access_size, &descr)) return false; + + descr.Print(bug_type); + return true; +} + +void ShadowAddressDescription::Print() const { + Printf("Address %p is located in the %s area.\n", addr, ShadowNames[kind]); +} + +void GlobalAddressDescription::Print(const char *bug_type) const { + for (int i = 0; i < size; i++) { + DescribeAddressRelativeToGlobal(addr, access_size, globals[i]); + if (bug_type && + 0 == internal_strcmp(bug_type, "initialization-order-fiasco") && + reg_sites[i]) { + Printf(" registered at:\n"); + StackDepotGet(reg_sites[i]).Print(); + } + } +} + +void StackAddressDescription::Print() const { + Decorator d; + char tname[128]; + Printf("%s", d.Location()); + Printf("Address %p is located in stack of thread T%d%s", addr, tid, + ThreadNameWithParenthesis(tid, tname, sizeof(tname))); + + if (!frame_descr) { + Printf("%s\n", d.EndLocation()); + return; + } + Printf(" at offset %zu in frame%s\n", offset, d.EndLocation()); + + // Now we print the frame where the alloca has happened. + // We print this frame as a stack trace with one element. + // The symbolizer may print more than one frame if inlining was involved. + // The frame numbers may be different than those in the stack trace printed + // previously. That's unfortunate, but I have no better solution, + // especially given that the alloca may be from entirely different place + // (e.g. use-after-scope, or different thread's stack). + Printf("%s", d.EndLocation()); + StackTrace alloca_stack(&frame_pc, 1); + alloca_stack.Print(); + + InternalMmapVector<StackVarDescr> vars(16); + if (!ParseFrameDescription(frame_descr, &vars)) { + Printf( + "AddressSanitizer can't parse the stack frame " + "descriptor: |%s|\n", + frame_descr); + // 'addr' is a stack address, so return true even if we can't parse frame + return; + } + uptr n_objects = vars.size(); + // Report the number of stack objects. + Printf(" This frame has %zu object(s):\n", n_objects); + + // Report all objects in this frame. + for (uptr i = 0; i < n_objects; i++) { + uptr prev_var_end = i ? vars[i - 1].beg + vars[i - 1].size : 0; + uptr next_var_beg = i + 1 < n_objects ? vars[i + 1].beg : ~(0UL); + PrintAccessAndVarIntersection(vars[i], offset, access_size, prev_var_end, + next_var_beg); + } + Printf( + "HINT: this may be a false positive if your program uses " + "some custom stack unwind mechanism or swapcontext\n"); + if (SANITIZER_WINDOWS) + Printf(" (longjmp, SEH and C++ exceptions *are* supported)\n"); + else + Printf(" (longjmp and C++ exceptions *are* supported)\n"); + + DescribeThread(GetThreadContextByTidLocked(tid)); +} + +void HeapAddressDescription::Print() const { + PrintHeapChunkAccess(addr, chunk_access); + + asanThreadRegistry().CheckLocked(); + AsanThreadContext *alloc_thread = GetThreadContextByTidLocked(alloc_tid); + StackTrace alloc_stack = GetStackTraceFromId(alloc_stack_id); + + char tname[128]; + Decorator d; + AsanThreadContext *free_thread = nullptr; + if (free_tid != kInvalidTid) { + free_thread = GetThreadContextByTidLocked(free_tid); + Printf("%sfreed by thread T%d%s here:%s\n", d.Allocation(), + free_thread->tid, + ThreadNameWithParenthesis(free_thread, tname, sizeof(tname)), + d.EndAllocation()); + StackTrace free_stack = GetStackTraceFromId(free_stack_id); + free_stack.Print(); + Printf("%spreviously allocated by thread T%d%s here:%s\n", d.Allocation(), + alloc_thread->tid, + ThreadNameWithParenthesis(alloc_thread, tname, sizeof(tname)), + d.EndAllocation()); + } else { + Printf("%sallocated by thread T%d%s here:%s\n", d.Allocation(), + alloc_thread->tid, *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201701081947.v08JlH08046885>