Skip to content

Commit

Permalink
8224853: CDS address sanitizer errors
Browse files Browse the repository at this point in the history
Reviewed-by: jiangli
Backport-of: 72daa46
  • Loading branch information
shipilev committed Jul 5, 2021
1 parent 65b215a commit 3f03476
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/hotspot/share/classfile/javaClasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ void java_lang_String::compute_offsets() {
#if INCLUDE_CDS
void java_lang_String::serialize_offsets(SerializeClosure* f) {
STRING_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
f->do_u4((u4*)&initialized);
f->do_bool(&initialized);
}
#endif

Expand Down Expand Up @@ -1558,7 +1558,7 @@ void java_lang_Class::compute_offsets() {

#if INCLUDE_CDS
void java_lang_Class::serialize_offsets(SerializeClosure* f) {
f->do_u4((u4*)&offsets_computed);
f->do_bool(&offsets_computed);
f->do_u4((u4*)&_init_lock_offset);

CLASS_FIELDS_DO(FIELD_SERIALIZE_OFFSET);
Expand Down
3 changes: 3 additions & 0 deletions src/hotspot/share/memory/iterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,9 @@ class SerializeClosure : public Closure {
// Read/write the 32-bit unsigned integer pointed to by p.
virtual void do_u4(u4* p) = 0;

// Read/write the bool pointed to by p.
virtual void do_bool(bool* p) = 0;

// Read/write the region specified.
virtual void do_region(u_char* start, size_t size) = 0;

Expand Down
10 changes: 10 additions & 0 deletions src/hotspot/share/memory/metaspaceShared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,11 @@ class WriteClosure : public SerializeClosure {
do_ptr(&ptr);
}

void do_bool(bool *p) {
void* ptr = (void*)(uintx(*p));
do_ptr(&ptr);
}

void do_tag(int tag) {
_dump_region->append_intptr_t((intptr_t)tag);
}
Expand Down Expand Up @@ -2004,6 +2009,11 @@ class ReadClosure : public SerializeClosure {
*p = (u4)(uintx(obj));
}

void do_bool(bool* p) {
intptr_t obj = nextPtr();
*p = (bool)(uintx(obj));
}

void do_tag(int tag) {
int old_tag;
old_tag = (int)(intptr_t)nextPtr();
Expand Down

1 comment on commit 3f03476

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.