Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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

Issues

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

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

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@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.

@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 <[email protected]>
@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.

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

Successfully merging this pull request may close these issues.

4 participants