-
Notifications
You must be signed in to change notification settings - Fork 12k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unix.StdCLibraryFunctions analysis regression #116421
Comments
@llvm/issue-subscribers-clang-static-analyzer Author: Andrew V. Louis (avlouis)
There seems to be a regression in the `unix.StdCLibraryFunctions` analysis check.
Found below is code for a small example. Running `clang --analyze sendto.c` produces warnings such as the following:
```
sendto.c:20:3: warning: The 1st argument to 'sendto' is -1 but should be >= 0 [unix.StdCLibraryFunctions]
20 | sendto(sockfd, NULL, 0, 0, NULL, 0);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
This happens for versions 19.1.2 and 19.1.3 but not 18.1.8. All acquired via this Github project. It seems the analysis pass believes Here is the code for
|
Hi, So in short, even static globals are subject to invalidation for opaque fn calls. Internally, I don't think we treat statics any differently, as we don't have a more sophisticated "address taken" analysis. Speaking of the appearing issue, I'll have a look to see what commit it bisects to to have better context. |
There seems to be a regression in the
unix.StdCLibraryFunctions
analysis check.Found below is code for a small example. Running
clang --analyze sendto.c
produces warnings such as the following:This happens for versions 19.1.2 and 19.1.3 but not 18.1.8. All acquired via this Github project.
It seems the analysis pass believes
some_function_outside_tu
can setsockfd
to-1
as removing the call to it or addingif(0 > sockfd) return 1;
between it and the call tosendto
resolves this warning.some_function_outside_tu
should not be able to modifysockfd
since the implementation is in a different translation unit andsockfd
isstatic
.Here is the code for
sendto.c
:The text was updated successfully, but these errors were encountered: