Mercurial > hg > icedtea8-forest > hotspot
changeset 10833:0277358b8fc2
8252904: VM crashes when JFR is used and JFR event class is transformed
Summary: set callers of ClassFileParser.parseClassFile responsible for putting ResourceMark
Reviewed-by: adinn
author | apetushkov |
---|---|
date | Thu, 01 Oct 2020 15:52:35 +0300 |
parents | 49dcf5b44dcb |
children | 5be342825cfd |
files | src/share/vm/classfile/classFileParser.cpp src/share/vm/classfile/classLoader.cpp src/share/vm/classfile/systemDictionary.cpp |
diffstat | 3 files changed, 31 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/vm/classfile/classFileParser.cpp Wed Sep 25 15:22:33 2019 -0700 +++ b/src/share/vm/classfile/classFileParser.cpp Thu Oct 01 15:52:35 2020 +0300 @@ -3746,7 +3746,13 @@ Handle class_loader(THREAD, loader_data->class_loader()); bool has_default_methods = false; bool declares_default_methods = false; - ResourceMark rm(THREAD); + // JDK-8252904: + // The stream (resource) attached to the instance klass may + // be reallocated by this method. When JFR is included the + // stream may need to survive beyond the end of the call. So, + // the caller is expected to declare the ResourceMark that + // determines the lifetime of resources allocated under this + // call. ClassFileStream* cfs = stream(); // Timing
--- a/src/share/vm/classfile/classLoader.cpp Wed Sep 25 15:22:33 2019 -0700 +++ b/src/share/vm/classfile/classLoader.cpp Thu Oct 01 15:52:35 2020 +0300 @@ -1179,6 +1179,11 @@ ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data(); Handle protection_domain; TempNewSymbol parsed_name = NULL; + // Callers are expected to declare a ResourceMark to determine + // the lifetime of any updated (resource) allocated under + // this call to parseClassFile + // We do not declare another ResourceMark here, reusing the one declared + // at the start of the method instanceKlassHandle result = parser.parseClassFile(h_name, loader_data, protection_domain,
--- a/src/share/vm/classfile/systemDictionary.cpp Wed Sep 25 15:22:33 2019 -0700 +++ b/src/share/vm/classfile/systemDictionary.cpp Thu Oct 01 15:52:35 2020 +0300 @@ -1026,14 +1026,21 @@ // // Note: "name" is updated. - instanceKlassHandle k = ClassFileParser(st).parseClassFile(class_name, - loader_data, - protection_domain, - host_klass, - cp_patches, - parsed_name, - true, - THREAD); + instanceKlassHandle k; + { + // Callers are expected to declare a ResourceMark to determine + // the lifetime of any updated (resource) allocated under + // this call to parseClassFile + ResourceMark rm(THREAD); + k = ClassFileParser(st).parseClassFile(class_name, + loader_data, + protection_domain, + host_klass, + cp_patches, + parsed_name, + true, + THREAD); + } if (host_klass.not_null() && k.not_null()) { @@ -1108,6 +1115,10 @@ // // Note: "name" is updated. + // Callers are expected to declare a ResourceMark to determine + // the lifetime of any updated (resource) allocated under + // this call to parseClassFile + ResourceMark rm(THREAD); ClassFileParser parser(st); instanceKlassHandle k = parser.parseClassFile(class_name, loader_data,