Skip to content

Commit 3f03476

Browse files
committed
8224853: CDS address sanitizer errors
Reviewed-by: jiangli Backport-of: 72daa46
1 parent 65b215a commit 3f03476

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

src/hotspot/share/classfile/javaClasses.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ void java_lang_String::compute_offsets() {
212212
#if INCLUDE_CDS
213213
void java_lang_String::serialize_offsets(SerializeClosure* f) {
214214
STRING_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
215-
f->do_u4((u4*)&initialized);
215+
f->do_bool(&initialized);
216216
}
217217
#endif
218218

@@ -1558,7 +1558,7 @@ void java_lang_Class::compute_offsets() {
15581558

15591559
#if INCLUDE_CDS
15601560
void java_lang_Class::serialize_offsets(SerializeClosure* f) {
1561-
f->do_u4((u4*)&offsets_computed);
1561+
f->do_bool(&offsets_computed);
15621562
f->do_u4((u4*)&_init_lock_offset);
15631563

15641564
CLASS_FIELDS_DO(FIELD_SERIALIZE_OFFSET);

src/hotspot/share/memory/iterator.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,9 @@ class SerializeClosure : public Closure {
317317
// Read/write the 32-bit unsigned integer pointed to by p.
318318
virtual void do_u4(u4* p) = 0;
319319

320+
// Read/write the bool pointed to by p.
321+
virtual void do_bool(bool* p) = 0;
322+
320323
// Read/write the region specified.
321324
virtual void do_region(u_char* start, size_t size) = 0;
322325

src/hotspot/share/memory/metaspaceShared.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,11 @@ class WriteClosure : public SerializeClosure {
842842
do_ptr(&ptr);
843843
}
844844

845+
void do_bool(bool *p) {
846+
void* ptr = (void*)(uintx(*p));
847+
do_ptr(&ptr);
848+
}
849+
845850
void do_tag(int tag) {
846851
_dump_region->append_intptr_t((intptr_t)tag);
847852
}
@@ -2004,6 +2009,11 @@ class ReadClosure : public SerializeClosure {
20042009
*p = (u4)(uintx(obj));
20052010
}
20062011

2012+
void do_bool(bool* p) {
2013+
intptr_t obj = nextPtr();
2014+
*p = (bool)(uintx(obj));
2015+
}
2016+
20072017
void do_tag(int tag) {
20082018
int old_tag;
20092019
old_tag = (int)(intptr_t)nextPtr();

0 commit comments

Comments
 (0)