Integrated: 8259623: JfrTypeSet::_subsystem_callback is left dangling after use
Aleksey Shipilev
shade at openjdk.java.net
Mon Mar 29 08:03:30 UTC 2021
On Thu, 25 Mar 2021 13:15:26 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:
> 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.
This pull request has now been integrated.
Changeset: 8ee9a05d
Author: Aleksey Shipilev <shade at openjdk.org>
URL: https://git.openjdk.java.net/jdk/commit/8ee9a05d
Stats: 33 lines in 2 files changed: 8 ins; 12 del; 13 mod
8259623: JfrTypeSet::_subsystem_callback is left dangling after use
Reviewed-by: mgronlun
-------------
PR: https://git.openjdk.java.net/jdk/pull/3192
More information about the hotspot-jfr-dev
mailing list