Skip to content

Conversation

@jdksjolen
Copy link
Contributor

@jdksjolen jdksjolen commented Jan 7, 2026

The implementation of the function os::map_memory_to_file calls os::release_memory if a mmap:ing to a fixed location succeeds but is not at the requested location. A POSIX implementation of mmap is not allowed to succeed and return a different base address if MAP_FIXED is supplied, so this is dead code. We can remove it.

Quote:

When MAP_FIXED is set in the flags argument, the implementation is informed that the value of pa shall be addr, exactly. If MAP_FIXED is set, mmap() may return MAP_FAILED and set errno to [EINVAL]. If a MAP_FIXED request is successful, the mapping established by mmap() replaces any previous mappings for the process' pages in the range [pa,pa+len).

https://pubs.opengroup.org/onlinepubs/009604499/functions/mmap.html


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-8325108: POSIX map_memory_to_file calls release_memory unnecessarily (Bug - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 29081

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jan 7, 2026

👋 Welcome back jsjolen! 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 Jan 7, 2026

@jdksjolen 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:

8325108: POSIX map_memory_to_file calls release_memory unnecessarily

Reviewed-by: dholmes, coleenp

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 200 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 8361382 8361382: NMT corruption: header canary broken as part of CodeBlob::purge() Jan 7, 2026
@openjdk openjdk bot added the hotspot-runtime hotspot-runtime-dev@openjdk.org label Jan 7, 2026
@openjdk
Copy link

openjdk bot commented Jan 7, 2026

@jdksjolen The following label will be automatically applied to this pull request:

  • hotspot-runtime

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

@jdksjolen jdksjolen changed the title 8361382: NMT corruption: header canary broken as part of CodeBlob::purge() 8325108 Jan 7, 2026
@openjdk openjdk bot changed the title 8325108 8325108: POSIX map_memory_to_file calls release_memory unnecessarily Jan 7, 2026
@jdksjolen jdksjolen marked this pull request as ready for review January 8, 2026 11:17
@openjdk openjdk bot added the rfr Pull request is ready for review label Jan 8, 2026
@mlbridge
Copy link

mlbridge bot commented Jan 8, 2026

Webrevs

warning("Failed mmap to file. (%s)", os::strerror(errno));
return nullptr;
}
if (base != nullptr && addr != base) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you turn this into an assert with a comment in the assert string why this isn't possible?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed!

Copy link
Contributor

Choose a reason for hiding this comment

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

I like the assert!

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.

Dead code removal seems fine. Thanks

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jan 8, 2026
Copy link
Contributor

@coleenp coleenp 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!

warning("Failed mmap to file. (%s)", os::strerror(errno));
return nullptr;
}
if (base != nullptr && addr != base) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I like the assert!

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

Labels

hotspot-runtime hotspot-runtime-dev@openjdk.org ready Pull request is ready to be integrated rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

3 participants