Skip to content

Commit

Permalink
JBR-3323 Exclude parts of VM code from sanitizer checks
Browse files Browse the repository at this point in the history
Exclude VM error-reporting code that treats memory as a raw sequence of
bytes from address sanitizer checks. This is needed to only get true
reports when running tests against the --enable-asan build.

(cherry picked from commit 4c2085b)
  • Loading branch information
mkartashev committed Jan 14, 2025
1 parent 560db37 commit 439d300
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/hotspot/share/runtime/os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1010,6 +1010,7 @@ static void print_hex_location(outputStream* st, const_address p, int unitsize,
}
}

ATTRIBUTE_NO_SANITIZE_ADDRESS("Memory is read raw here without any regard for objects' boundaries")
void os::print_hex_dump(outputStream* st, const_address start, const_address end, int unitsize,
bool print_ascii, int bytes_per_line, const_address logical_start, const_address highlight_address) {
constexpr int max_bytes_per_line = 64;
Expand Down
6 changes: 6 additions & 0 deletions src/hotspot/share/utilities/compilerWarnings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,10 @@
#define END_ALLOW_FORBIDDEN_FUNCTIONS \
PRAGMA_DIAG_POP

#if defined(__clang__) || defined (__GNUC__)
# define ATTRIBUTE_NO_SANITIZE_ADDRESS(reason_for_exclusion) __attribute__((no_sanitize_address))
#else
# define ATTRIBUTE_NO_SANITIZE_ADDRESS(reason_for_exclusion)
#endif

#endif // SHARE_UTILITIES_COMPILERWARNINGS_HPP
1 change: 1 addition & 0 deletions src/hotspot/share/utilities/vmError.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@ void VMError::clear_step_start_time() {
// could be nested report_and_die() calls on stack (see above). Only one
// thread can report error, so large buffers are statically allocated in data
// segment.
ATTRIBUTE_NO_SANITIZE_ADDRESS("Memory is read raw here without any regard for objects' boundaries")
void VMError::report(outputStream* st, bool _verbose) {
// Used by reattempt step logic
static int continuation = 0;
Expand Down

0 comments on commit 439d300

Please sign in to comment.