Skip to content

Commit 72daa46

Browse files
committed
8224853: CDS address sanitizer errors
Reviewed-by: iklam, dholmes
1 parent c66a7b7 commit 72daa46

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

src/hotspot/share/classfile/javaClasses.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ void java_lang_String::compute_offsets() {
198198
#if INCLUDE_CDS
199199
void java_lang_String::serialize_offsets(SerializeClosure* f) {
200200
STRING_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
201-
f->do_u4((u4*)&initialized);
201+
f->do_bool(&initialized);
202202
}
203203
#endif
204204

@@ -1566,7 +1566,7 @@ void java_lang_Class::compute_offsets() {
15661566

15671567
#if INCLUDE_CDS
15681568
void java_lang_Class::serialize_offsets(SerializeClosure* f) {
1569-
f->do_u4((u4*)&offsets_computed);
1569+
f->do_bool(&offsets_computed);
15701570
f->do_u4((u4*)&_init_lock_offset);
15711571

15721572
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
@@ -322,6 +322,9 @@ class SerializeClosure : public Closure {
322322
// Read/write the 32-bit unsigned integer pointed to by p.
323323
virtual void do_u4(u4* p) = 0;
324324

325+
// Read/write the bool pointed to by p.
326+
virtual void do_bool(bool* p) = 0;
327+
325328
// Read/write the region specified.
326329
virtual void do_region(u_char* start, size_t size) = 0;
327330

src/hotspot/share/memory/metaspaceShared.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1935,6 +1935,11 @@ void ReadClosure::do_u4(u4* p) {
19351935
*p = (u4)(uintx(obj));
19361936
}
19371937

1938+
void ReadClosure::do_bool(bool* p) {
1939+
intptr_t obj = nextPtr();
1940+
*p = (bool)(uintx(obj));
1941+
}
1942+
19381943
void ReadClosure::do_tag(int tag) {
19391944
int old_tag;
19401945
old_tag = (int)(intptr_t)nextPtr();

src/hotspot/share/memory/metaspaceShared.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ class WriteClosure : public SerializeClosure {
125125
do_ptr(&ptr);
126126
}
127127

128+
void do_bool(bool *p) {
129+
void* ptr = (void*)(uintx(*p));
130+
do_ptr(&ptr);
131+
}
132+
128133
void do_tag(int tag) {
129134
_dump_region->append_intptr_t((intptr_t)tag);
130135
}
@@ -154,6 +159,8 @@ class ReadClosure : public SerializeClosure {
154159

155160
void do_u4(u4* p);
156161

162+
void do_bool(bool *p);
163+
157164
void do_tag(int tag);
158165

159166
void do_oop(oop *p);

0 commit comments

Comments
 (0)