[PATCH] D97699: [analyzer] Add InvalidPtrChecker

Zurab Tsinadze via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 1 09:08:39 PST 2021


zukatsinadze added a comment.

Please suggest which package to use for the checker. 
CERT rules are ENV, however, it deals with non-ENV functions as well.

Also, I am having a problem with `checkDeadSymbols`, it is similar to one xazax.hun faced here: http://reviews.llvm.org/D14203 (many many years ago)
`envp` memory region is marked dead too early in case of aliasing. Please check the snippets, the second one is problematic:

  int main(int argc, char **argv, char *envp[]) {
    putenv((char*) "NAME=VALUE"); // envp invalidated
    envp[0]; // gives error
  }
  
  int main(int argc, char **argv, char *envp[]) {
    char **e = envp;
    putenv((char*) "NAME=VALUE"); // envp invalidated
    e[0]; // does not give error :(
  
    // warnOnDeadSymbol reports 'envp' dead here
  } 
  
  int main(int argc, char **argv, char *envp[]) {
    char **e = envp;
    putenv((char*) "NAME=VALUE"); // envp invalidated
    e[0]; // gives error again
  
    /*
      use 'envp' somehow here
    */
  }


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97699/new/

https://reviews.llvm.org/D97699



More information about the cfe-commits mailing list