JDK-8302189 : Mark assertion failures noreturn
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 21
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2023-02-10
  • Updated: 2023-03-13
  • Resolved: 2023-03-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 21
21 b13Fixed
Related Reports
Blocks :  
Blocks :  
Blocks :  
Blocks :  
Relates :  
Relates :  
Relates :  
Description
HotSpot assertion failures and similar operations should have the reporting function called in the failure case marked with attribute `[[noreturn]]`.

This may permit the compiler to generate better code in some cases. This matters even for production, since some of the operations (such as `guarantee` and `ShouldNotReachHere`) are present in product builds, not just debug builds.

This also addresses the problems encountered in JDK-8294031.  Because the failure reporting function used by assert is not "noreturn", the compiler is analyzing the continuation from a failed assert as potentially having the values that would result in an assertion failure (in this case, a variable having a null value).  Doing so, it discovers a use of that variable in a context where a null value is UB, and so issues a warning.

Of course, marking these functions noreturn will require actually making them not return.  That's going to require some significant changes.

Comments
Changeset: 5fa9bd45 Author: Kim Barrett <kbarrett@openjdk.org> Date: 2023-03-08 02:37:06 +0000 URL: https://git.openjdk.org/jdk/commit/5fa9bd458232a0b5f31b1e7e5a4a2b1f4047da35
08-03-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/12845 Date: 2023-03-03 04:04:25 +0000
03-03-2023