From 0d3a3771c3777d3dd1fec8dc8faed5fd02b06830 Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Thu, 13 Jun 2024 14:02:01 +0000 Subject: [PATCH] 8333887: ubsan: unsafe.cpp:247:13: runtime error: store to null pointer of type 'volatile int' Reviewed-by: lucy, mdoerr --- src/hotspot/share/prims/unsafe.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/hotspot/share/prims/unsafe.cpp b/src/hotspot/share/prims/unsafe.cpp index 880f1f6ab5d..d290627c197 100644 --- a/src/hotspot/share/prims/unsafe.cpp +++ b/src/hotspot/share/prims/unsafe.cpp @@ -242,6 +242,11 @@ public: return normalize_for_read(*addr()); } + // we use this method at some places for writing to 0 e.g. to cause a crash; + // ubsan does not know that this is the desired behavior +#if defined(__clang__) || defined(__GNUC__) +__attribute__((no_sanitize("undefined"))) +#endif void put(T x) { GuardUnsafeAccess guard(_thread); *addr() = normalize_for_write(x);