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

JBR-7246 DCEVM: Fix SIGSEGV in method_hash on redefinition #402

Closed
wants to merge 2 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
54 changes: 31 additions & 23 deletions src/hotspot/share/prims/resolvedMethodTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,47 +427,55 @@ void ResolvedMethodTable::adjust_method_entries_dcevm(bool * trace_name_printed)
_local_table->remove(thread, lookup);

InstanceKlass* newer_klass = InstanceKlass::cast(old_method->method_holder()->new_version());
Method* newer_method;
Method* newer_method = nullptr;

// Method* new_method;
if (old_method->is_deleted()) {
newer_method = Universe::throw_no_such_method_error();
} else {
newer_method = newer_klass->method_with_idnum(old_method->orig_method_idnum());

assert(newer_method != NULL, "method_with_idnum() should not be NULL");
assert(newer_klass == newer_method->method_holder(), "call after swapping redefined guts");
assert(old_method != newer_method, "sanity check");
// TODO: JBR21 - check why the newer_method can be nullptr
// assert(newer_method != NULL, "method_with_idnum() should not be NULL");

Thread* thread = Thread::current();
ResolvedMethodTableLookup lookup(thread, method_hash(newer_method), newer_method);
ResolvedMethodGet rmg(thread, newer_method);
if (newer_method != nullptr) {
assert(newer_klass == newer_method->method_holder(), "call after swapping redefined guts");
assert(old_method != newer_method, "sanity check");

if (_local_table->get(thread, lookup, rmg)) {
// old method was already adjusted if new method exists in _the_table
Thread *thread = Thread::current();
ResolvedMethodTableLookup lookup(thread, method_hash(newer_method), newer_method);
ResolvedMethodGet rmg(thread, newer_method);

if (_local_table->get(thread, lookup, rmg)) {
// old method was already adjusted if new method exists in _the_table
continue;
}
}
}

log_debug(redefine, class, update)("Adjusting method: '%s' of new class %s", newer_method->name_and_sig_as_C_string(), newer_klass->name()->as_C_string());
if (newer_method != nullptr) {
log_debug(redefine,class, update)("Adjusting method: '%s' of new class %s", newer_method->name_and_sig_as_C_string(), newer_klass->name()->as_C_string());

// 2. Update method
java_lang_invoke_ResolvedMethodName::set_vmtarget(mem_name, newer_method);
java_lang_invoke_ResolvedMethodName::set_vmholder(mem_name, newer_method->method_holder()->java_mirror());
// 2. Update method
java_lang_invoke_ResolvedMethodName::set_vmtarget(mem_name, newer_method);
java_lang_invoke_ResolvedMethodName::set_vmholder(mem_name, newer_method->method_holder()->java_mirror());

newer_klass->set_has_resolved_methods();
newer_klass->set_has_resolved_methods();

ResourceMark rm;
if (!(*trace_name_printed)) {
log_debug(redefine, class, update)("adjust: name=%s", old_method->method_holder()->external_name());
*trace_name_printed = true;
}
log_debug(redefine, class, update, constantpool)
ResourceMark rm;
if (!(*trace_name_printed)) {
log_debug(redefine, class, update)("adjust: name=%s", old_method->method_holder()->external_name());
*trace_name_printed = true;
}
log_debug(redefine,class, update, constantpool)
("ResolvedMethod method update: %s(%s)",
newer_method->name()->as_C_string(), newer_method->signature()->as_C_string());
newer_method->name()->as_C_string(), newer_method->signature()->as_C_string());

// 3. add updated method to table again
add_method(newer_method, Handle(thread, mem_name));
// 3. add updated method to table again
add_method(newer_method, Handle(thread, mem_name));
} else {
log_warning(redefine,class, update)("New method: '%s' of new class %s not found.", old_method->name_and_sig_as_C_string(), newer_klass->name()->as_C_string());
}
}

}
Expand Down