RFR: 8259623: JfrTypeSet::_subsystem_callback is left dangling after use
Aleksey Shipilev
shade at openjdk.java.net
Thu Mar 25 13:29:17 UTC 2021
SonarCloud instance reports the bug in cases like:
"Address of stack memory associated with local variable 'callback' is still referred to by the global variable '_subsystem_callback' upon returning to the caller. This will be a dangling reference"
For example:
static void clear_packages() {
ClearArtifact<PkgPtr> clear;
ClearPackageCallback callback(&clear);
_subsystem_callback = &callback;
do_packages();
}
I understand that `_subsystem_callback` is assigned to be used in do_packages(), but it would indeed be left dangling. The patch moves callback installation into the callback superclass itself. This way, we also guarantee that `_subsystem_callback` is not set before installation (i.e. check for overlapping callback installations), and make sure it is `NULL` after use.
-------------
Commit messages:
- 8259623: JfrTypeSet::_subsystem_callback is left dangling after use
Changes: https://git.openjdk.java.net/jdk/pull/3192/files
Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=3192&range=00
Issue: https://bugs.openjdk.java.net/browse/JDK-8259623
Stats: 33 lines in 2 files changed: 8 ins; 12 del; 13 mod
Patch: https://git.openjdk.java.net/jdk/pull/3192.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/3192/head:pull/3192
PR: https://git.openjdk.java.net/jdk/pull/3192
More information about the hotspot-jfr-dev
mailing list