Skip to content

Conversation

@savoptik
Copy link
Contributor

@savoptik savoptik commented Jun 26, 2025

The defect has been detected and confirmed in the function IterateOverHeapObjectClosure::do_object() located in the file src/hotspot/share/prims/jvmtiTagMap.cpp with static code analysis. This defect can potentially lead to a null pointer dereference.

The pointer oop o is passed to the constructor of the CallbackWrapper class, where it is dereferenced without a null check.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8360664: Null pointer dereference in src/hotspot/share/prims/jvmtiTagMap.cpp in IterateOverHeapObjectClosure::do_object() (Bug - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/26002/head:pull/26002
$ git checkout pull/26002

Update a local copy of the PR:
$ git checkout pull/26002
$ git pull https://git.openjdk.org/jdk.git pull/26002/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 26002

View PR using the GUI difftool:
$ git pr show -t 26002

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/26002.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 26, 2025

👋 Welcome back asemenov! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Jun 26, 2025

@savoptik This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8360664: Null pointer dereference in src/hotspot/share/prims/jvmtiTagMap.cpp in IterateOverHeapObjectClosure::do_object()

Found by Linux Verification Center (linuxtesting.org) with SVACE.
Signed-off-by: Artem Semenov <savoptik@altlinux.org>.

Reviewed-by: sspitsyn, amenkov, cjplummer

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 72 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot changed the title 8360664 Null pointer dereference in src/hotspot/share/prims/jvmtiTagMap.cpp in IterateOverHeapObjectClosure::do_object() 8360664: Null pointer dereference in src/hotspot/share/prims/jvmtiTagMap.cpp in IterateOverHeapObjectClosure::do_object() Jun 26, 2025
@openjdk openjdk bot added the rfr Pull request is ready for review label Jun 26, 2025
@openjdk
Copy link

openjdk bot commented Jun 26, 2025

@savoptik The following labels will be automatically applied to this pull request:

  • hotspot
  • serviceability

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added serviceability serviceability-dev@openjdk.org hotspot hotspot-dev@openjdk.org labels Jun 26, 2025
@mlbridge
Copy link

mlbridge bot commented Jun 26, 2025

Webrevs

@savoptik
Copy link
Contributor Author

/issue add 8360670

@openjdk
Copy link

openjdk bot commented Jun 26, 2025

@savoptik
Adding additional issue to issue list: 8360670: Null pointer dereference in src/hotspot/share/prims/jvmtiTagMap.cpp in IterateThroughHeapObjectClosure::do_object().

…ap.cpp in IterateOverHeapObjectClosure::do_object()

Found by Linux Verification Center (linuxtesting.org) with SVACE.
signed-off-by: Artem Semenov <savoptik@altlinux.org>
@savoptik savoptik force-pushed the asemenov/JDK-8360664 branch from ee6a0ff to e69c49c Compare June 26, 2025 13:57
@openjdk
Copy link

openjdk bot commented Jun 26, 2025

@savoptik Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration. See OpenJDK Developers’ Guide for more information.

@plummercj
Copy link
Contributor

It's concerning that we don't have tests cases that uncover these bugs. Perhaps it's not actually possible for NULL to be passed when constructing CallbackWrapper.

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a false positive from the static code analyzer. If we are iterating over the heap then the closure is only ever passed actual oops, so it can't be null.

At most I would add an assert, but generally my understanding is that the user of any closure has the responsibility of passing it valid input.

@sspitsyn
Copy link
Contributor

At most I would add an assert, but generally my understanding is that the user of any closure has the responsibility of passing it valid input.

Adding asserts sounds like a good suggestion.

@sspitsyn
Copy link
Contributor

I'm a little bit confused why we have twp bugs for this issue.
The bug JDK-8360670 seems to be a dup of:
JDK-8360664: Null pointer dereference in src/hotspot/share/prims/jvmtiTagMap.cpp in IterateOverHeapObjectClosure::do_object()
Should it be closed as a dup?

@savoptik
Copy link
Contributor Author

At most I would add an assert, but generally my understanding is that the user of any closure has the responsibility of passing it valid input.

Adding asserts sounds like a good suggestion.

It seems to me that this won’t be a big problem in this form. I’ve just moved the existing check higher up, where it will prevent dereferencing a null pointer.

However, if you confirm that this is not acceptable, I will replace the check with assert.

@plummercj
Copy link
Contributor

At most I would add an assert, but generally my understanding is that the user of any closure has the responsibility of passing it valid input.

Adding asserts sounds like a good suggestion.

It seems to me that this won’t be a big problem in this form. I’ve just moved the existing check higher up, where it will prevent dereferencing a null pointer.

However, if you confirm that this is not acceptable, I will replace the check with assert.

I think it is a matter of having the code accurately document the input requirements. Checking for null and returning makes it look like passing null is ok and might happen. That's not the case though. It should never happen and adding an assert properly documents this.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jul 1, 2025
Copy link
Contributor

@plummercj plummercj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix looks good, but I assume that the static analysis tool that reported the false warning is still going to report it, or at least do so in product builds where the assert code is not included.


// invoked for each object in the heap
void IterateOverHeapObjectClosure::do_object(oop o) {
assert(o != nullptr, "Parameter 'o' must not be null!");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert(o != nullptr, "Parameter 'o' must not be null!");
assert(o != nullptr, "Heap iteration should never produce null");

Same with the other assertion please. Though as @plummercj states I don't see how this will help with the static analysis tool.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with the other assertion please. Though as @plummercj states I don't see how this will help with the static analysis tool.

done.

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Jul 1, 2025
@savoptik
Copy link
Contributor Author

savoptik commented Jul 1, 2025

/summary
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Signed-off-by: Artem Semenov savoptik@altlinux.org.

@openjdk
Copy link

openjdk bot commented Jul 1, 2025

@savoptik Setting summary to:

Found by Linux Verification Center (linuxtesting.org) with SVACE.
Signed-off-by: Artem Semenov <savoptik@altlinux.org>.

Copy link
Contributor

@sspitsyn sspitsyn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks okay.
However, I agree with David it is not going to address the issue with static analysis tool.
Is it right?
Also, why are there two bugs associated with this PR?

@savoptik
Copy link
Contributor Author

savoptik commented Jul 1, 2025

This looks okay. However, I agree with David it is not going to address the issue with static analysis tool. Is it right? Also, why are there two bugs associated with this PR?

Because there are two identical analyzer detections in similar code sections of this file. I created one ticket for each detection. However, I fixed both issues with a single PR.

Regarding the analyzer, we will rerun the analysis with assert enabled and check if it helps to suppress the analyzer warnings

@sspitsyn
Copy link
Contributor

sspitsyn commented Jul 1, 2025

Because there are two identical analyzer detections in similar code sections of this file. I created one ticket for each detection. However, I fixed both issues with a single PR.

Is it a specific requirement to create a separate bug for each complain? Normally, one bug for both has to be enough. One bug would be even enough for multiple complains in several files of the same development area.

@sspitsyn
Copy link
Contributor

sspitsyn commented Jul 1, 2025

Regarding the analyzer, we will rerun the analysis with assert enabled and check if it helps to suppress the analyzer warnings

Thanks!

@savoptik
Copy link
Contributor Author

savoptik commented Jul 1, 2025

Because there are two identical analyzer detections in similar code sections of this file. I created one ticket for each detection. However, I fixed both issues with a single PR.

Is it a specific requirement to create a separate bug for each complain? Normally, one bug for both has to be enough. One bug would be even enough for multiple complains in several files of the same development area.

TNX

@sspitsyn
Copy link
Contributor

sspitsyn commented Jul 2, 2025

I'm suggesting to close JDK-8360670 as a dup of JDK-8360664.

@savoptik
Copy link
Contributor Author

savoptik commented Jul 2, 2025

I'm suggesting to close JDK-8360670 as a dup of JDK-8360664.

Ok.

@savoptik
Copy link
Contributor Author

savoptik commented Jul 2, 2025

/issue remove 8360670

@openjdk
Copy link

openjdk bot commented Jul 2, 2025

@savoptik
Removing additional issue from issue list: 8360670.

Copy link
Contributor

@sspitsyn sspitsyn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thank you for closing second bug as a dup.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jul 2, 2025
@savoptik
Copy link
Contributor Author

savoptik commented Jul 3, 2025

@alexmenkov @plummercj @dholmes-ora do you mind the integration?

@alexmenkov
Copy link

I'm fine with the fix, the only question if it helps with the analysis tool.

@plummercj
Copy link
Contributor

Same here. I just don't want to see the CR refiled if the analysis tool still complains.

@savoptik
Copy link
Contributor Author

savoptik commented Jul 7, 2025

/integrate

@openjdk
Copy link

openjdk bot commented Jul 7, 2025

Going to push as commit e9a4341.
Since your change was applied there have been 104 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jul 7, 2025
@openjdk openjdk bot closed this Jul 7, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jul 7, 2025
@openjdk
Copy link

openjdk bot commented Jul 7, 2025

@savoptik Pushed as commit e9a4341.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotspot hotspot-dev@openjdk.org integrated Pull request has been integrated serviceability serviceability-dev@openjdk.org

Development

Successfully merging this pull request may close these issues.

5 participants