Repository navigation
[pulse] treat calls to C functions with mismatched arity as unknown - #2142
Open
VladimirMakaev wants to merge 1 commit into
Open
VladimirMakaev wants to merge 1 commit into
VladimirMakaev wants to merge 1 commit into
Conversation
VladimirMakaev
force-pushed
the
pulse-c-arity-mismatch
branch
from
October 2, 2026 07:57
c0a2f35 to
ed036fb
Compare
Contributor
|
@jvillard could you have a look? |
VladimirMakaev
force-pushed
the
pulse-c-arity-mismatch
branch
2 times, most recently
from
October 5, 2026 06:52
802e1d1 to
1837216
Compare
VladimirMakaev
marked this pull request as ready for review
October 5, 2026 15:27
VladimirMakaev
added a commit
to VladimirMakaev/infer
that referenced
this pull request
Oct 5, 2026
C functions are identified by name only, so a call can resolve to a definition with another number of parameters (another program analyzed together, an unprototyped declaration, a function pointer cast). Every pre/post of that definition then failed with a `FormalActualLength` contradiction, silently dropping all paths through the call. Upstream-PR: meta#2142 PR-Head: 1837216 PR-Base: 9cc2641
VladimirMakaev
force-pushed
the
pulse-c-arity-mismatch
branch
from
October 7, 2026 15:54
1837216 to
39707f5
Compare
Contributor
|
Could you check if #2078 happens to solve this too? |
Contributor
Author
|
I checked: #2078 doesn't cover this. Its changes are all behind |
Contributor
|
There are conflicts now |
VladimirMakaev
force-pushed
the
pulse-c-arity-mismatch
branch
from
November 5, 2026 14:47
39707f5 to
277c4d5
Compare
Contributor
Author
|
Rebased on top of #2078. |
C functions are identified by name only, so a call can resolve to a definition with another number
of parameters (another program analyzed together, an unprototyped declaration, a function pointer
cast). Every pre/post of that definition then failed with a `FormalActualLength` contradiction,
silently dropping all paths through the call.
```c
// conn.c
#include <stddef.h>
#include <sys/socket.h>
int npe_after_shutdown(int fd) {
int* p = NULL;
shutdown(fd, SHUT_RDWR);
return *p; // Infer missed: null dereference
}
// plugin.c, part of another program
void shutdown(void) {}
```
Treat such calls as unknown: skip the summary and havoc the arguments; a `noreturn` attribute of the
definition still ends the path. A new stats counter, `pulse_unknown_calls_arity_mismatch`, counts
these calls.
Limitations: the summary is skipped even when the definition is the real callee (e.g. casts), and a
call-site `noreturn` declaration (like `err()`) is lost when the definition returns.
## Test plan
New `c/pulse` tests `arity_mismatch.c` and `arity_mismatch2.c`: more or fewer actuals across files,
a cast function pointer, a function pointer variable and a K&R definition; variadic, matching-arity
and `noreturn` controls; `FP_` tests for the limitations. On main the `_bad` tests after mismatched
calls report nothing. All codetoanalyze tests pass.
VladimirMakaev
force-pushed
the
pulse-c-arity-mismatch
branch
from
November 5, 2026 17:53
277c4d5 to
3cf5cd8
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
C functions are identified by name only, so a call can resolve to a definition with another number
of parameters (another program analyzed together, an unprototyped declaration, a function pointer
cast). Every pre/post of that definition then failed with a
FormalActualLengthcontradiction,silently dropping all paths through the call.
Treat such calls as unknown: skip the summary and havoc the arguments; a
noreturnattribute of thedefinition still ends the path. A new stats counter,
pulse_unknown_calls_arity_mismatch, countsthese calls.
Limitations: the summary is skipped even when the definition is the real callee (e.g. casts), and a
call-site
noreturndeclaration (likeerr()) is lost when the definition returns.Test plan
New
c/pulsetestsarity_mismatch.candarity_mismatch2.c: more or fewer actuals across files,a cast function pointer, a function pointer variable and a K&R definition; variadic, matching-arity
and
noreturncontrols;FP_tests for the limitations. On main the_badtests after mismatchedcalls report nothing. All codetoanalyze tests pass.