Skip to content

Commit 0d3a377

Browse files
committed
8333887: ubsan: unsafe.cpp:247:13: runtime error: store to null pointer of type 'volatile int'
Reviewed-by: lucy, mdoerr
1 parent 9d8439c commit 0d3a377

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/hotspot/share/prims/unsafe.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,11 @@ class MemoryAccess : StackObj {
242242
return normalize_for_read(*addr());
243243
}
244244

245+
// we use this method at some places for writing to 0 e.g. to cause a crash;
246+
// ubsan does not know that this is the desired behavior
247+
#if defined(__clang__) || defined(__GNUC__)
248+
__attribute__((no_sanitize("undefined")))
249+
#endif
245250
void put(T x) {
246251
GuardUnsafeAccess guard(_thread);
247252
*addr() = normalize_for_write(x);

0 commit comments

Comments
 (0)