Skip to content
This repository has been archived by the owner. It is now read-only.

8259027: NullPointerException in makeMappedSegment due to NULL Unmapper when length of segment is 0 #83

Closed
wants to merge 3 commits into from

Conversation

@mcimadamore
Copy link
Contributor

@mcimadamore mcimadamore commented Jan 5, 2021

When the size of the memory map is zero, FileChannelImpl returns a null Unmapper - this creates issues to the mapped memory segment implementation.

To fix, I've created an empty mapped segment class which is initialized to sensible defaults, and whose implenentation of force/load etc. do nothing.

We already had a test for this condition - but the test was missing the @Test annotation, so it was not run! I've now beefed up the test a bit to make sure that mapped segment operations do not throw.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8259027: NullPointerException in makeMappedSegment due to NULL Unmapper when length of segment is 0

Reviewers

Download

$ git fetch https://git.openjdk.java.net/jdk16 pull/83/head:pull/83
$ git checkout pull/83

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Jan 5, 2021

👋 Welcome back mcimadamore! 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.

Loading

@openjdk openjdk bot added the rfr label Jan 5, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Jan 5, 2021

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

  • core-libs

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.

Loading

@openjdk openjdk bot added the core-libs label Jan 5, 2021
@mlbridge
Copy link

@mlbridge mlbridge bot commented Jan 5, 2021

Webrevs

Loading

return new MappedMemorySegmentImpl(unmapperProxy.address(), unmapperProxy, bytesSize,
modes, scope);
} else {
return new EmptyMappedMemorySegmentImpl();
Copy link
Member

@ChrisHegarty ChrisHegarty Jan 5, 2021

Choose a reason for hiding this comment

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

While a little pedantic, should the mapMode be considered so that an empty mapped segment will feature the expected access modes when queried through the accessModes API ?

Loading

Copy link
Contributor Author

@mcimadamore mcimadamore Jan 5, 2021

Choose a reason for hiding this comment

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

Ugh - yes, good point

Loading

Copy link
Member

@ChrisHegarty ChrisHegarty left a comment

Looks good to me.

Loading

@openjdk
Copy link

@openjdk openjdk bot commented Jan 5, 2021

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

8259027: NullPointerException in makeMappedSegment due to NULL Unmapper when length of segment is 0

Reviewed-by: chegar, uschindler

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 2 new commits pushed to the master branch:

  • bbc2e95: 8257906: JFR: RecordingStream leaks memory
  • 6775113: 8258393: Shenandoah: "graph should be schedulable" assert failure

Please see this link for an up-to-date comparison between the source branch of this pull request and 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.

Loading

@openjdk openjdk bot added the ready label Jan 5, 2021
Copy link
Member

@uschindler uschindler left a comment

Looks fine!
In fact it's more complicated than the workaround, but this allows to call load() or force().

Loading

@mcimadamore
Copy link
Contributor Author

@mcimadamore mcimadamore commented Jan 5, 2021

/integrate

Loading

@openjdk openjdk bot closed this Jan 5, 2021
@openjdk openjdk bot added integrated and removed ready rfr labels Jan 5, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Jan 5, 2021

@mcimadamore Since your change was applied there have been 2 commits pushed to the master branch:

  • bbc2e95: 8257906: JFR: RecordingStream leaks memory
  • 6775113: 8258393: Shenandoah: "graph should be schedulable" assert failure

Your commit was automatically rebased without conflicts.

Pushed as commit b7940aa.

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

Loading

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
3 participants