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

Dangling pointer warning as error in libjdwp/util.c

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: External
    • Icon: P4 P4
    • None
    • 25
    • core-svc
    • None
    • x86_64
    • linux_alpine

      When building the JDK native libs with opt-level HIGHEST on Alpine with gcc 12.2.1 (gcc (Alpine 12.2.1_git20220924-r10) 12.2.1 20220924) I run into this warning as error :

      src/jdk.jdwp.agent/share/native/libjdwp/util.c:758:31: error: dangling pointer 'xx' to 'signature' may be used [-Werror=dangling-pointer=]
        758 | if (xx == NULL || *(xx + 1) == 0) {
                                  | ^~~~~~~~~
       
      src/jdk.jdwp.agent/share/native/libjdwp/util.c:715:11: note: 'signature' declared here
        715 | char *signature = NULL;
            | ^~~~~~~~~
      cc1: all warnings being treated as errors

      Disabling the dangling pointer warning for this file works as a workaround.

      jvmtiError
      methodReturnType(jmethodID method, char *typeKey)
      {
          char *signature;
          jvmtiError error;

          signature = NULL;
          error = methodSignature(method, NULL, &signature, NULL);
          if (error == JVMTI_ERROR_NONE) {
              if (signature == NULL ) {
                  error = AGENT_ERROR_INVALID_TAG;
              } else {
                  char * xx;

                  xx = strchr(signature, ')');
                  if (xx == NULL || *(xx + 1) == 0) {
                      error = AGENT_ERROR_INVALID_TAG;
                  } else {
                     *typeKey = *(xx + 1);
                  }
                  jvmtiDeallocate(signature);
              }
          }
          return error;
      }

            Unassigned Unassigned
            mbaesken Matthias Baesken
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: