JDK-8294594 : Fix cast-function-type warnings in signal handling code
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 20
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2022-09-29
  • Updated: 2025-11-05
  • Resolved: 2022-10-18
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 17 JDK 20
17.0.18Fixed 20 b20Fixed
Related Reports
Relates :  
Description
After JDK-8294314, we would have signals_posix.cpp excluded with cast-function-type warning:

```
/home/shade/trunks/jdk/src/hotspot/os/posix/signals_posix.cpp: In function 'int SR_initialize()':
/home/shade/trunks/jdk/src/hotspot/os/posix/signals_posix.cpp:1727:20: error: cast between incompatible function types from 'void (*)(int, siginfo_t*, ucontext_t*)' to 'void (*)(int)' [-Werror=cast-function-type]
 1727 |   act.sa_handler = (void (*)(int)) SR_handler;
      |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~
```

A closer look would reveal that we are using the wrong slots for SR_handler, `sa_handler` vs `sig_handler`, which manifests in type cast errors. `man sigaction` says:

```
       If SA_SIGINFO is specified in sa_flags, then sa_sigaction (instead  of  sa_handler)  specifies  the  signal-handling
       function for signum.  This function receives three arguments, as described below.
```
Comments
[jdk17u-fix-request] Approval Request from Aleksey Shipilëv Fixes another batch of warnings, which enables smoother compiler toolchain upgrades. Needed to unblock MacOS 15 upgrade in GHA. Patch does not apply cleanly, but conflicts are simple to resolve, see 17u PR. Passes all tests. Risk is low: eliminates some (odd) casts, no bug tail since initial integration several years ago.
03-11-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk17u-dev/pull/4125 Date: 2025-10-28 12:11:16 +0000
30-10-2025

Changeset: b06f1b14 Author: Aleksey Shipilev <shade@openjdk.org> Date: 2022-10-18 08:45:28 +0000 URL: https://git.openjdk.org/jdk/commit/b06f1b149c8f8a49d4e42c4b782a4b3a22aa79f6
18-10-2022

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/10494 Date: 2022-09-29 16:12:11 +0000
29-09-2022