Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8294594

Fix cast-function-type warnings in signal handling code

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 20
    • 20
    • hotspot
    • b20

    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.
      ```

      Attachments

        Issue Links

          Activity

            People

              shade Aleksey Shipilev
              shade Aleksey Shipilev
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: