Skip to content

Commit

Permalink
8333149: ubsan : memset on nullptr target detected in jvmtiEnvBase.cp…
Browse files Browse the repository at this point in the history
…p get_object_monitor_usage

Reviewed-by: sspitsyn, mdoerr
  • Loading branch information
MBaesken committed May 29, 2024
1 parent fed2b56 commit 43a2f17
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/hotspot/share/prims/jvmtiEnvBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1557,8 +1557,12 @@ JvmtiEnvBase::get_object_monitor_usage(JavaThread* calling_thread, jobject objec
// this object has a heavyweight monitor

// null out memory for robustness
memset(ret.waiters, 0, ret.waiter_count * sizeof(jthread *));
memset(ret.notify_waiters, 0, ret.notify_waiter_count * sizeof(jthread *));
if (ret.waiters != nullptr) {
memset(ret.waiters, 0, ret.waiter_count * sizeof(jthread *));
}
if (ret.notify_waiters != nullptr) {
memset(ret.notify_waiters, 0, ret.notify_waiter_count * sizeof(jthread *));
}

if (ret.waiter_count > 0) { // we have contending threads waiting to enter/re-enter the monitor
// identify threads waiting to enter and re-enter the monitor
Expand Down

3 comments on commit 43a2f17

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@MBaesken
Copy link
Member Author

Choose a reason for hiding this comment

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

/backport jdk21u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 43a2f17 Jun 7, 2024

Choose a reason for hiding this comment

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

@MBaesken Could not automatically backport 43a2f173 to openjdk/jdk21u-dev due to conflicts in the following files:

  • src/hotspot/share/prims/jvmtiEnvBase.cpp

Please fetch the appropriate branch/commit and manually resolve these conflicts by using the following commands in your personal fork of openjdk/jdk21u-dev. Note: these commands are just some suggestions and you can use other equivalent commands you know.

# Fetch the up-to-date version of the target branch
$ git fetch --no-tags https://git.openjdk.org/jdk21u-dev.git master:master

# Check out the target branch and create your own branch to backport
$ git checkout master
$ git checkout -b backport-MBaesken-43a2f173-master

# Fetch the commit you want to backport
$ git fetch --no-tags https://git.openjdk.org/jdk.git 43a2f17342af8f5bf1f5823df9fa0bf0bdfdfce2

# Backport the commit
$ git cherry-pick --no-commit 43a2f17342af8f5bf1f5823df9fa0bf0bdfdfce2
# Resolve conflicts now

# Commit the files you have modified
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport 43a2f17342af8f5bf1f5823df9fa0bf0bdfdfce2'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk21u-dev with the title Backport 43a2f17342af8f5bf1f5823df9fa0bf0bdfdfce2.

Below you can find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 43a2f173 from the openjdk/jdk repository.

The commit being backported was authored by Matthias Baesken on 29 May 2024 and was reviewed by Serguei Spitsyn and Martin Doerr.

Thanks!

Please sign in to comment.