Skip to content

8361433: [Big Endian] assert(verify_guards()) failed: Expected valid memory guards after 8357601 #26140

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

Closed

Conversation

TheRealMDoerr
Copy link
Contributor

@TheRealMDoerr TheRealMDoerr commented Jul 4, 2025

Big Endian fix for JDK-8357601.

Note: The first commit is only a Big Endian fix. The code looks still wrong for platforms which don't support unaligned accesses. Also see UseUnalignedAccesses.
The second commit changes to check os::is_readable_range().


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-8361433: [Big Endian] assert(verify_guards()) failed: Expected valid memory guards after 8357601 (Bug - P2)

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 26140

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 4, 2025

👋 Welcome back mdoerr! 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 Jul 4, 2025

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

@openjdk openjdk bot added the rfr Pull request is ready for review label Jul 4, 2025
@openjdk
Copy link

openjdk bot commented Jul 4, 2025

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

@openjdk openjdk bot added the hotspot-runtime hotspot-runtime-dev@openjdk.org label Jul 4, 2025
@mlbridge
Copy link

mlbridge bot commented Jul 4, 2025

Webrevs

@@ -119,7 +119,7 @@ class GuardedMemory : StackObj { // Wrapper on stack
// We may not be able to dereference directly so use
// SafeFetch. It doesn't matter if the value read happens
// to be 0xFF as that is not what we expect anyway.
u_char val = (u_char) SafeFetch32((int*)c, 0xFF);
u_char val = (u_char) (SafeFetch32((int*)c, 0xFF) BIG_ENDIAN_ONLY(>> 24));
Copy link
Member

@tstuefe tstuefe Jul 5, 2025

Choose a reason for hiding this comment

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

Your fix is fine. Pre-existing: I wonder about the SafeFetch. A byte pointer traverses byte-wise over the memory. We use it to load a 32-bit value via SafeFetch32. 3/4 of those loads will be unaligned and also redundant. (I am surprised the unaligned access works on all platforms).

The guards themselves can be located at unaligned addresses I think, so we cannot just use int loads. Therefore I would have just used the old code without safefetch but preceded it with a safefetch check:

u_char* c = (u_char*) _guard;
+ if (!os::is_readable_pointer(align_up(c, BytesPerInt))) {
+   return false;
+ }
   u_char* end = c + GUARD_SIZE;
   while (c < end) {
     if (*c != badResourceValue) {
       return false;
     }
     c++;
   }

I think that would be pragmatic since the guard is only 16 byte and the chance of a guard straddling a page boundary is very small. But if one wanted to be more careful, one could use os::is_readable_range() instead.

@dholmes-ora does this make sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, Thomas! I've changed to use os::is_readable_range(). Note that alignment is already handled inside of that function. Please take a look!

Copy link
Member

@dholmes-ora dholmes-ora Jul 6, 2025

Choose a reason for hiding this comment

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

@TheRealMDoerr , @tstuefe let me do a backout of JDK-8357601 in the morning. I need that fix to be complete and safe so it can be backported in a simple manner. Thanks.

I will look into @tstuefe suggested alternative.

@dholmes-ora
Copy link
Member

The original change has been backed out. Sorry for the inconvenience, and thanks for the suggested fix.

@TheRealMDoerr
Copy link
Contributor Author

Will be handled by JDK-8361447.

@TheRealMDoerr TheRealMDoerr deleted the 8361433_BigEndian_guard branch July 7, 2025 08:29
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 rfr Pull request is ready for review
Development

Successfully merging this pull request may close these issues.

3 participants