mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8302102: Disable ASan for SafeFetch and os::print_hex_dump
Reviewed-by: dholmes, stuefe
This commit is contained in:
parent
9ccf8ad91f
commit
98a392c4fc
4 changed files with 35 additions and 8 deletions
|
@ -26,6 +26,7 @@
|
|||
#include "precompiled.hpp"
|
||||
|
||||
#include "runtime/safefetch.hpp"
|
||||
#include "sanitizers/address.hpp"
|
||||
#include "utilities/debug.hpp"
|
||||
#include "utilities/globalDefinitions.hpp"
|
||||
|
||||
|
@ -63,7 +64,7 @@ bool handle_safefetch(int sig, address ignored1, void* ignored2) {
|
|||
}
|
||||
|
||||
template <class T>
|
||||
static bool _SafeFetchXX_internal(const T *adr, T* result) {
|
||||
ATTRIBUTE_NO_ASAN static bool _SafeFetchXX_internal(const T *adr, T* result) {
|
||||
|
||||
T n = 0;
|
||||
|
||||
|
|
|
@ -26,12 +26,13 @@
|
|||
#ifndef OS_WINDOWS_SAFEFETCH_WINDOWS_HPP
|
||||
#define OS_WINDOWS_SAFEFETCH_WINDOWS_HPP
|
||||
|
||||
#include "sanitizers/address.hpp"
|
||||
#include "utilities/globalDefinitions.hpp"
|
||||
|
||||
// On windows, we use structured exception handling to implement SafeFetch
|
||||
|
||||
template <class T>
|
||||
inline T SafeFetchXX(const T* adr, T errValue) {
|
||||
ATTRIBUTE_NO_ASAN inline T SafeFetchXX(const T* adr, T errValue) {
|
||||
T v = 0;
|
||||
__try {
|
||||
v = *adr;
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
#include "runtime/threadSMR.hpp"
|
||||
#include "runtime/vmOperations.hpp"
|
||||
#include "runtime/vm_version.hpp"
|
||||
#include "sanitizers/address.hpp"
|
||||
#include "services/attachListener.hpp"
|
||||
#include "services/mallocTracker.hpp"
|
||||
#include "services/mallocHeader.inline.hpp"
|
||||
|
@ -942,6 +943,16 @@ bool os::print_function_and_library_name(outputStream* st,
|
|||
return have_function_name || have_library_name;
|
||||
}
|
||||
|
||||
ATTRIBUTE_NO_ASAN static void print_hex_readable_pointer(outputStream* st, address p,
|
||||
int unitsize) {
|
||||
switch (unitsize) {
|
||||
case 1: st->print("%02x", *(u1*)p); break;
|
||||
case 2: st->print("%04x", *(u2*)p); break;
|
||||
case 4: st->print("%08x", *(u4*)p); break;
|
||||
case 8: st->print("%016" FORMAT64_MODIFIER "x", *(u8*)p); break;
|
||||
}
|
||||
}
|
||||
|
||||
void os::print_hex_dump(outputStream* st, address start, address end, int unitsize,
|
||||
int bytes_per_line, address logical_start) {
|
||||
assert(unitsize == 1 || unitsize == 2 || unitsize == 4 || unitsize == 8, "just checking");
|
||||
|
@ -960,12 +971,7 @@ void os::print_hex_dump(outputStream* st, address start, address end, int unitsi
|
|||
st->print(PTR_FORMAT ": ", p2i(logical_p));
|
||||
while (p < end) {
|
||||
if (is_readable_pointer(p)) {
|
||||
switch (unitsize) {
|
||||
case 1: st->print("%02x", *(u1*)p); break;
|
||||
case 2: st->print("%04x", *(u2*)p); break;
|
||||
case 4: st->print("%08x", *(u4*)p); break;
|
||||
case 8: st->print("%016" FORMAT64_MODIFIER "x", *(u8*)p); break;
|
||||
}
|
||||
print_hex_readable_pointer(st, p, unitsize);
|
||||
} else {
|
||||
st->print("%*.*s", 2*unitsize, 2*unitsize, "????????????????");
|
||||
}
|
||||
|
|
|
@ -29,6 +29,25 @@
|
|||
#include <sanitizer/asan_interface.h>
|
||||
#endif
|
||||
|
||||
// ATTRIBUTE_NO_ASAN
|
||||
//
|
||||
// Function attribute which informs the compiler to not instrument memory accesses in the function.
|
||||
// Useful if the function is known to do something dangerous, such as reading previous stack frames
|
||||
// or reading arbitrary regions of memory when dumping during a crash.
|
||||
#ifdef ADDRESS_SANITIZER
|
||||
#if defined(TARGET_COMPILER_gcc)
|
||||
// GCC-like, including Clang.
|
||||
#define ATTRIBUTE_NO_ASAN __attribute__((no_sanitize_address))
|
||||
#elif defined(TARGET_COMPILER_visCPP)
|
||||
// Microsoft Visual C++
|
||||
#define ATTRIBUTE_NO_ASAN __declspec(no_sanitize_address)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef ATTRIBUTE_NO_ASAN
|
||||
#define ATTRIBUTE_NO_ASAN
|
||||
#endif
|
||||
|
||||
// ASAN_POISON_MEMORY_REGION()/ASAN_UNPOISON_MEMORY_REGION()
|
||||
//
|
||||
// Poisons/unpoisons the specified memory region. When ASan is available this is the macro of the
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue