Skip to content

Commit

Permalink
8313816: Accessing jmethodID might lead to spurious crashes (1)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbachorik committed Aug 7, 2023
1 parent 90d795a commit cae3bb6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/actions/do-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ runs:
$build_dir/configure.log \
$build_dir/make-support/failure-summary.log \
$build_dir/make-support/failure-logs/* \
$build_dir/make/hs_err*.log \
failure-logs/ 2> /dev/null || true
echo 'failure=true' >> $GITHUB_OUTPUT
fi
Expand Down
7 changes: 4 additions & 3 deletions src/hotspot/share/oops/instanceKlass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -587,9 +587,6 @@ void InstanceKlass::deallocate_contents(ClassLoaderData* loader_data) {
// Also remove mirror from handles
loader_data->remove_handle(_java_mirror);

// Need to take this class off the class loader data list.
loader_data->remove_class(this);

// The array_klass for this class is created later, after error handling.
// For class redefinition, we keep the original class so this scratch class
// doesn't have an array class. Either way, assert that there is nothing
Expand Down Expand Up @@ -2828,6 +2825,10 @@ void InstanceKlass::release_C_heap_structures(bool release_sub_metadata) {
jmethodID* jmeths = methods_jmethod_ids_acquire();
if (jmeths != (jmethodID*)nullptr) {
release_set_methods_jmethod_ids(nullptr);
size_t count = (size_t)jmeths[0];
for (size_t i = 1; i <= count; i++) {
*((Method**)jmeths[i]) = nullptr;
}
FreeHeap(jmeths);
}

Expand Down
4 changes: 3 additions & 1 deletion src/hotspot/share/oops/method.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,9 @@ class Method : public Metadata {
// (see AsyncGetCallTrace support for Forte Analyzer) and this
// needs to be async-safe. No allocation should be done and
// so handles are not used to avoid deadlock.
jmethodID find_jmethod_id_or_null() { return method_holder()->jmethod_id_or_null(this); }
jmethodID find_jmethod_id_or_null() {
return method_holder() != nullptr ? method_holder()->jmethod_id_or_null(this) : nullptr;
}

// Support for inlining of intrinsic methods
vmIntrinsicID intrinsic_id() const { return (vmIntrinsicID) _intrinsic_id; }
Expand Down

0 comments on commit cae3bb6

Please sign in to comment.