Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8341844: [lworld] Test crashing in genzgc in ZBarrier::mark_from_old_slow_path(zaddress)+0x4c #1321

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 37 additions & 7 deletions src/hotspot/share/gc/z/zBarrierSet.inline.hpp
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@
#ifndef SHARE_GC_Z_ZBARRIERSET_INLINE_HPP
#define SHARE_GC_Z_ZBARRIERSET_INLINE_HPP

#include "gc/z/zAddress.hpp"
#include "gc/z/zBarrierSet.hpp"

#include "gc/shared/accessBarrierSupport.inline.hpp"
@@ -479,24 +480,53 @@ inline void ZBarrierSet::AccessBarrier<decorators, BarrierSetT>::clone_in_heap(o
ZIterator::oop_iterate(dst, &cl_sg);
}

static inline void copy_primitive_payload(const void* src, const void* dst, const size_t payload_size_bytes, size_t& copied_bytes) {
if (payload_size_bytes == 0) {
return;
}
void* src_payload = (void*)(address(src) + copied_bytes);
void* dst_payload = (void*)(address(dst) + copied_bytes);
Copy::copy_value_content(src_payload, dst_payload, payload_size_bytes);
copied_bytes += payload_size_bytes;
}

template <DecoratorSet decorators, typename BarrierSetT>
inline void ZBarrierSet::AccessBarrier<decorators, BarrierSetT>::value_copy_in_heap(void* src, void* dst, InlineKlass* md, LayoutKind lk) {
if (md->contains_oops()) {
// src/dst aren't oops, need offset to adjust oop map offset
const address src_oop_addr_offset = ((address) src) - md->first_field_offset();
// Iterate over each oop map, performing:
// 1) possibly raw copy for any primitive payload before each map
// 2) load and store barrier for each oop
// 3) possibly raw copy for any primitive payload trailer

// src/dst may not be oops, need offset to adjust oop map offset
const address src_oop_addr_offset = ((address) src) - md->first_field_offset();
OopMapBlock* map = md->start_of_nonstatic_oop_maps();
const OopMapBlock* const end = map + md->nonstatic_oop_map_count();
size_t size_in_bytes = md->layout_size_in_bytes(lk);
size_t copied_bytes = 0;
while (map != end) {
const address soop_address = src_oop_addr_offset + map->offset();
zpointer *p = (zpointer*) soop_address;
for (const zpointer* const end = p + map->count(); p < end; p++) {
ZBarrier::load_barrier_on_oop_field(p);
zpointer *src_p = (zpointer*)(src_oop_addr_offset + map->offset());
const uintptr_t oop_offset = uintptr_t(src_p) - uintptr_t(src);
zpointer *dst_p = (zpointer*)(uintptr_t(dst) + oop_offset);

// Copy any leading primitive payload before every cluster of oops
assert(copied_bytes < oop_offset || copied_bytes == oop_offset, "Negative sized leading payload segment");
copy_primitive_payload(src, dst, oop_offset - copied_bytes, copied_bytes);

// Copy a cluster of oops
for (const zpointer* const src_end = src_p + map->count(); src_p < src_end; src_p++, dst_p++) {
oop_copy_one(dst_p, src_p);
copied_bytes += sizeof(zpointer);
}
map++;
}

// Copy trailing primitive payload after potential oops
assert(copied_bytes < size_in_bytes || copied_bytes == size_in_bytes, "Negative sized trailing payload segment");
copy_primitive_payload(src, dst, size_in_bytes - copied_bytes, copied_bytes);
} else {
Raw::value_copy_in_heap(src, dst, md, lk);
}
Raw::value_copy_in_heap(src, dst, md, lk);
}

//
8 changes: 3 additions & 5 deletions test/hotspot/jtreg/ProblemList-generational-zgc.txt
Original file line number Diff line number Diff line change
@@ -118,13 +118,11 @@ serviceability/sa/sadebugd/SADebugDTest.java 8307393 generic-
vmTestbase/gc/gctests/MemoryEaterMT/MemoryEaterMT.java 8289582 windows-x64

# Valhalla...
compiler/valhalla/inlinetypes/TestArrayCopyWithOops.java 8341844 generic-all
compiler/valhalla/inlinetypes/TestCallingConvention.java 8341844 generic-all
compiler/valhalla/inlinetypes/TestNullableInlineTypes.java 8341844 generic-all
runtime/valhalla/inlinetypes/InlineTypesTest.java 8341844 generic-all
compiler/valhalla/inlinetypes/TestArrayCopyWithOops.java 8346466 generic-all

compiler/valhalla/inlinetypes/TestStressReturnBuffering.java 8341846 generic-all

# Once jdk-24+22 are merged (remove singlegen zgc) together with 8341844, many of these issues are resolved...
compiler/valhalla/inlinetypes/TestStressReturnBuffering.java 8341846 generic-all
compiler/valhalla/inlinetypes/TestUnloadedInlineTypeArray.java 8341848 generic-all
compiler/valhalla/inlinetypes/TestArrays.java 8341848 generic-all
compiler/valhalla/inlinetypes/TestBasicFunctionality.java 8341848 generic-all
17 changes: 17 additions & 0 deletions test/hotspot/jtreg/runtime/valhalla/inlinetypes/InlineOops.java
Original file line number Diff line number Diff line change
@@ -106,6 +106,23 @@
* runtime.valhalla.inlinetypes.InlineOops
*/

/**
* @test id=ZXint
* @requires vm.gc.Z
* @summary Test embedding oops into Inline types (sanity check with interpreter only the most complex GC)
* @modules java.base/jdk.internal.value
* java.base/jdk.internal.vm.annotation
* @library /test/lib /test/jdk/java/lang/invoke/common
* @enablePreview
* @compile Person.java InlineOops.java
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
* jdk.test.whitebox.WhiteBox$WhiteBoxPermission
* @run main/othervm -Xint -XX:+UnlockExperimentalVMOptions -XX:+UseZGC -Xmx128m
* -XX:+UnlockDiagnosticVMOptions -XX:+ZVerifyViews -XX:InlineFieldMaxFlatSize=160
* -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
* runtime.valhalla.inlinetypes.InlineOops
*/

/**
* @test id=ZGen
* @requires vm.gc.Z & vm.opt.final.ZGenerational