RFR: 8278239: vmTestbase/nsk/jvmti/RedefineClasses/StressRedefine failed with EXCEPTION_ACCESS_VIOLATION at 0x000000000000000d

Coleen Phillimore coleenp at openjdk.java.net
Tue Dec 21 22:44:19 UTC 2021


On Tue, 21 Dec 2021 22:21:14 GMT, Serguei Spitsyn <sspitsyn at openjdk.org> wrote:

>> Thanks to @stefank and @fisk for the diagnosis.  ZGC is looking at metadata in unloaded nmethods, but redefinition doesn't keep this metadata from being deallocated.  Change the iterators that mark metadata in use to walk unloaded nmethods as well as other alive nmethods.
>> 
>> The test case reproduces the crash on windows if run in an 100 iteration loop.  This fix does not crash in the same test.  Also ran tier1-6.
>
> Coleen,
> Thank you for fixing this issue!
> I've posted one question. Other than that it looks good to me.
> Thanks,
> Serguei

@sspitsyn Thanks for looking at this.  Can you review the JDK 18 PR instead?

> src/hotspot/share/code/codeCache.cpp line 681:
> 
>> 679: void CodeCache::metadata_do(MetadataClosure* f) {
>> 680:   assert_locked_or_safepoint(CodeCache_lock);
>> 681:   NMethodIterator iter(NMethodIterator::only_alive);
> 
> The `CodeCache::metadata_do` is used in `MetadataOnStackMark::MetadataOnStackMark`.
> Besides `RedefineClasses` the `MetadataOnStackMark` is also used in `ClassLoaderDataGraph::walk_metadata_and_clean_metaspaces`.
> Is the change at L681 correct for `ClassLoaderDataGraph::walk_metadata_and_clean_metaspaces`as well?

Yes, in ClassLoaderDataGraph::walk_metadata_and_clean_metaspaces, it calls the version of MetadataOnStackMark that doesn't call CodeCache::metadata_do - it only walks the metadata that was saved from the full redefinition walk:

caller:
  MetadataOnStackMark md_on_stack(walk_all_metadata, /*redefinition_walk*/false);

callee:
    if (redefinition_walk) {
      // We have to walk the whole code cache during redefinition.
      CodeCache::metadata_do(&md_on_stack);
    } else {
      CodeCache::old_nmethods_do(&md_on_stack);
    }

During redefinition, we have to walk the unloaded nmethods as well as the alive nmethods.

-------------

PR: https://git.openjdk.java.net/jdk/pull/6900


More information about the hotspot-dev mailing list