Skip to content

8311301: MethodExitTest may fail with stack buffer overrun#14770

Closed
djelinski wants to merge 2 commits intoopenjdk:masterfrom
djelinski:methodexittest
Closed

8311301: MethodExitTest may fail with stack buffer overrun#14770
djelinski wants to merge 2 commits intoopenjdk:masterfrom
djelinski:methodexittest

Conversation

@djelinski
Copy link
Member

@djelinski djelinski commented Jul 4, 2023

Please review this test-only fix that fixes the size of variables that are used in methods that expect a pointer.

On Windows, type long is 32 bits, pointers are 64 bits large. The method GetThreadLocalStorage writes a pointer (64 bits) to the address given by its parameter, which overflows a long. The code generated by VS compiler ignores this, but the code generated by clang crashes the test.

No new tests. MethodExitTest continues to pass on supported platforms, and passes on clang+win with this fix.


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-8311301: MethodExitTest may fail with stack buffer overrun (Bug - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 14770

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 4, 2023

👋 Welcome back djelinski! 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 openjdk bot changed the title 8311301 8311301: MethodExitTest may fail with stack buffer overrun Jul 4, 2023
@openjdk
Copy link

openjdk bot commented Jul 4, 2023

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

  • serviceability

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.

@openjdk openjdk bot added the serviceability serviceability-dev@openjdk.org label Jul 4, 2023
@djelinski djelinski marked this pull request as ready for review July 4, 2023 19:50
@openjdk openjdk bot added the rfr Pull request is ready for review label Jul 4, 2023
@mlbridge
Copy link

mlbridge bot commented Jul 4, 2023

Webrevs

Copy link
Contributor

@kevinjwalls kevinjwalls 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 to me. 8-)

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.

Why not type them void* as expected by the API, and then you can also drop the casts?

Thanks.

@djelinski
Copy link
Member Author

The diff to intptr_t was an order of magnitude smaller. But I agree, the code looks better without the casts.

@openjdk
Copy link

openjdk bot commented Jul 5, 2023

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

8311301: MethodExitTest may fail with stack buffer overrun

Reviewed-by: kevinw, dholmes, cjplummer, sspitsyn

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 26 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 added the ready Pull request is ready to be integrated label Jul 5, 2023
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.
Thanks,
Serguei

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.

Looks good albeit more extensive than I had envisaged.

Thanks.

Comment on lines +126 to +127
static const void* const tls_data1 = (const void*)0x111;
static const void* const tls_data2 = (const void*)0x222;
Copy link
Member

Choose a reason for hiding this comment

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

Was this necessitated by the change to void*? If so I had not expected that.

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess I could have changed the logging code to use "%d", (int)(intptr_t)tls_data and call it a day, but it would be ugly.

@djelinski
Copy link
Member Author

Thanks for the reviews!

/integrate

@openjdk
Copy link

openjdk bot commented Jul 6, 2023

Going to push as commit 3d813ae.
Since your change was applied there have been 26 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 6, 2023
@openjdk openjdk bot closed this Jul 6, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jul 6, 2023
@openjdk
Copy link

openjdk bot commented Jul 6, 2023

@djelinski Pushed as commit 3d813ae.

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

@djelinski djelinski deleted the methodexittest branch July 6, 2023 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Development

Successfully merging this pull request may close these issues.

5 participants