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

Signal handler should save/restore errno

XMLWordPrintable

    • b20
    • x86
    • linux_redhat_3.0

        A licensee and their customer think signal handlers in JVM should save and
        restore errno. Otherwise, errno might be overwritten by signal handler.

        A native method in customer application call msgrcv().
        When the return value of msgrcv() is -1, errno is set to ECHILD.
        The OS team in the licensee says,
        "When some signal interruption occurs and the signal handler re-writes errno,
         such situation might occur."

        They look into the source code of signal handler in JVM and find out the following
        portion.

        =====
        .......
        JVM_handle_linux_signal(int sig,
                     siginfo_t* info,
                     void* ucVoid,
                     int abort_if_unrecognized)
        {
          ucontext_t* uc = (ucontext_t*) ucVoid;

          if (sig == SIGCHLD) {
            // cleanup zombie pid for child thread
            ::waitpid(-1, 0, WNOHANG);
            return 1;
          }
        .....
        ======

        There seems a possibility that errno is replaced by ECHILD in waitpid.
        Our customer believes that signal handlers should save errno and restore
        on return.
        The above example is waitpid/ECHILD case.
        They think also errno may be overwritten in other system calls.

        (Please read comment section also. There are more specific resuests from the licensee.)

              hseigel Harold Seigel (Inactive)
              tbaba Tadayuki Baba (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: