8259623: JfrTypeSet::_subsystem_callback is left dangling after use
Reviewed-by: mgronlun
This commit is contained in:
parent
1f54ed07ad
commit
8ee9a05d37
@ -425,15 +425,13 @@ static bool write_klasses() {
|
||||
KlassWriter kw(_writer, _class_unload);
|
||||
KlassWriterRegistration kwr(&kw, ®);
|
||||
if (_leakp_writer == NULL) {
|
||||
KlassCallback callback(&kwr);
|
||||
_subsystem_callback = &callback;
|
||||
KlassCallback callback(&_subsystem_callback, &kwr);
|
||||
do_klasses();
|
||||
} else {
|
||||
LeakKlassWriter lkw(_leakp_writer, _class_unload);
|
||||
CompositeKlassWriter ckw(&lkw, &kw);
|
||||
CompositeKlassWriterRegistration ckwr(&ckw, ®);
|
||||
CompositeKlassCallback callback(&ckwr);
|
||||
_subsystem_callback = &callback;
|
||||
CompositeKlassCallback callback(&_subsystem_callback, &ckwr);
|
||||
do_klasses();
|
||||
}
|
||||
if (is_initial_typeset_for_chunk()) {
|
||||
@ -474,8 +472,7 @@ static void register_klass(Klass* klass) {
|
||||
static void register_klasses() {
|
||||
assert(!_artifacts->has_klass_entries(), "invariant");
|
||||
KlassArtifactRegistrator reg(_artifacts);
|
||||
RegisterKlassCallback callback(®);
|
||||
_subsystem_callback = &callback;
|
||||
RegisterKlassCallback callback(&_subsystem_callback, ®);
|
||||
ClassLoaderDataGraph::classes_do(®ister_klass);
|
||||
}
|
||||
|
||||
@ -552,8 +549,7 @@ static void write_packages() {
|
||||
_artifacts->iterate_klasses(kpw);
|
||||
ClearArtifact<PkgPtr> clear;
|
||||
PackageWriterWithClear pwwc(&pw, &clear);
|
||||
PackageCallback callback(&pwwc);
|
||||
_subsystem_callback = &callback;
|
||||
PackageCallback callback(&_subsystem_callback, &pwwc);
|
||||
do_packages();
|
||||
} else {
|
||||
LeakPackageWriter lpw(_leakp_writer, _class_unload);
|
||||
@ -562,8 +558,7 @@ static void write_packages() {
|
||||
_artifacts->iterate_klasses(kcpw);
|
||||
ClearArtifact<PkgPtr> clear;
|
||||
CompositePackageWriterWithClear cpwwc(&cpw, &clear);
|
||||
CompositePackageCallback callback(&cpwwc);
|
||||
_subsystem_callback = &callback;
|
||||
CompositePackageCallback callback(&_subsystem_callback, &cpwwc);
|
||||
do_packages();
|
||||
}
|
||||
_artifacts->tally(pw);
|
||||
@ -573,8 +568,7 @@ typedef JfrArtifactCallbackHost<PkgPtr, ClearArtifact<PkgPtr> > ClearPackageCall
|
||||
|
||||
static void clear_packages() {
|
||||
ClearArtifact<PkgPtr> clear;
|
||||
ClearPackageCallback callback(&clear);
|
||||
_subsystem_callback = &callback;
|
||||
ClearPackageCallback callback(&_subsystem_callback, &clear);
|
||||
do_packages();
|
||||
}
|
||||
|
||||
@ -651,8 +645,7 @@ static void write_modules() {
|
||||
_artifacts->iterate_klasses(kmw);
|
||||
ClearArtifact<ModPtr> clear;
|
||||
ModuleWriterWithClear mwwc(&mw, &clear);
|
||||
ModuleCallback callback(&mwwc);
|
||||
_subsystem_callback = &callback;
|
||||
ModuleCallback callback(&_subsystem_callback, &mwwc);
|
||||
do_modules();
|
||||
} else {
|
||||
LeakModuleWriter lmw(_leakp_writer, _class_unload);
|
||||
@ -661,8 +654,7 @@ static void write_modules() {
|
||||
_artifacts->iterate_klasses(kcpw);
|
||||
ClearArtifact<ModPtr> clear;
|
||||
CompositeModuleWriterWithClear cmwwc(&cmw, &clear);
|
||||
CompositeModuleCallback callback(&cmwwc);
|
||||
_subsystem_callback = &callback;
|
||||
CompositeModuleCallback callback(&_subsystem_callback, &cmwwc);
|
||||
do_modules();
|
||||
}
|
||||
_artifacts->tally(mw);
|
||||
@ -672,8 +664,7 @@ typedef JfrArtifactCallbackHost<ModPtr, ClearArtifact<ModPtr> > ClearModuleCallb
|
||||
|
||||
static void clear_modules() {
|
||||
ClearArtifact<ModPtr> clear;
|
||||
ClearModuleCallback callback(&clear);
|
||||
_subsystem_callback = &callback;
|
||||
ClearModuleCallback callback(&_subsystem_callback, &clear);
|
||||
do_modules();
|
||||
}
|
||||
|
||||
@ -785,8 +776,7 @@ static void write_classloaders() {
|
||||
_artifacts->iterate_klasses(kmcw);
|
||||
ClearArtifact<CldPtr> clear;
|
||||
CldWriterWithClear cldwwc(&cldw, &clear);
|
||||
CldCallback callback(&cldwwc);
|
||||
_subsystem_callback = &callback;
|
||||
CldCallback callback(&_subsystem_callback, &cldwwc);
|
||||
do_class_loaders();
|
||||
} else {
|
||||
LeakCldWriter lcldw(_leakp_writer, _class_unload);
|
||||
@ -797,8 +787,7 @@ static void write_classloaders() {
|
||||
_artifacts->iterate_klasses(kmccldw);
|
||||
ClearArtifact<CldPtr> clear;
|
||||
CompositeCldWriterWithClear ccldwwc(&ccldw, &clear);
|
||||
CompositeCldCallback callback(&ccldwwc);
|
||||
_subsystem_callback = &callback;
|
||||
CompositeCldCallback callback(&_subsystem_callback, &ccldwwc);
|
||||
do_class_loaders();
|
||||
}
|
||||
_artifacts->tally(cldw);
|
||||
@ -808,8 +797,7 @@ typedef JfrArtifactCallbackHost<CldPtr, ClearArtifact<CldPtr> > ClearCLDCallback
|
||||
|
||||
static void clear_classloaders() {
|
||||
ClearArtifact<CldPtr> clear;
|
||||
ClearCLDCallback callback(&clear);
|
||||
_subsystem_callback = &callback;
|
||||
ClearCLDCallback callback(&_subsystem_callback, &clear);
|
||||
do_class_loaders();
|
||||
}
|
||||
|
||||
|
@ -58,9 +58,17 @@ class JfrArtifactClosure {
|
||||
template <typename T, typename Callback>
|
||||
class JfrArtifactCallbackHost : public JfrArtifactClosure {
|
||||
private:
|
||||
JfrArtifactClosure** _subsystem_callback_loc;
|
||||
Callback* _callback;
|
||||
public:
|
||||
JfrArtifactCallbackHost(Callback* callback) : _callback(callback) {}
|
||||
JfrArtifactCallbackHost(JfrArtifactClosure** subsystem_callback_loc, Callback* callback) :
|
||||
_subsystem_callback_loc(subsystem_callback_loc), _callback(callback) {
|
||||
assert(*_subsystem_callback_loc == NULL, "Subsystem callback should not be set yet");
|
||||
*_subsystem_callback_loc = this;
|
||||
}
|
||||
~JfrArtifactCallbackHost() {
|
||||
*_subsystem_callback_loc = NULL;
|
||||
}
|
||||
void do_artifact(const void* artifact) {
|
||||
(*_callback)(reinterpret_cast<T const&>(artifact));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user