Skip to content
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

Duplicate root-cause entries in PerWildPtrStats.json for expression variables in shared header files #730

Open
mattmccutchen-cci opened this issue Oct 19, 2021 · 0 comments

Comments

@mattmccutchen-cci
Copy link
Member

IIUC, 3C currently doesn't try to deduplicate expression ConstraintVariables generated for header files shared by multiple translation units because we don't yet have a good way to do it; PSL-based deduplication would cause incorrect behavior in some examples we care about with multiple expression ConstraintVariables at the same PSL. For the most part, this duplication has no observable ill effects: each time the body of a shared inline function is processed, 3C generates another copy of the constraint subgraph (connected to the same non-expression ConstraintVariables), but these multiple copies have the same ultimate effect on the solution for the non-expression ConstraintVariables that a single copy would.

However, I noticed one ill effect: a root cause related to an expression ConstraintVariable can be listed multiple times in PerWildPtrStats.json. Currently, only one root-cause warning will be generated because those warnings are deduplicated by PSL, but that may need to be changed to atom-based deduplication, at which point the warnings would exhibit the same duplication as PerWildPtrStats.json.

An example:

shared.h:

inline void oops(void) {
  int *p = 1;
}

a.c and b.c each containing:

#include "shared.h"

After running 3c -dump-stats -output-dir=out.checked a.c b.c --, we get in PerWildPtrStats.json:

{"RootCauseStats":[{"ConstraintKey":1, "Name":"ImplicitCastExpr_1", "Reason":"Cast from int to int *", "InSrc":0, "Location":"/home/matt/test/expression-twice-20211019/shared.h:2:12:12", "AtomsAffected":1, "AtomsScore":5.000000e-01, "PtrsAffected":1,"PtrsScore":5.000000e-01,"SubReasons":[]},
{"ConstraintKey":2, "Name":"ImplicitCastExpr_2", "Reason":"Cast from int to int *", "InSrc":0, "Location":"/home/matt/test/expression-twice-20211019/shared.h:2:12:12", "AtomsAffected":1, "AtomsScore":5.000000e-01, "PtrsAffected":1,"PtrsScore":5.000000e-01,"SubReasons":[]}]}

If we discover other ill effects of duplication of expression ConstraintVariables, it may make sense to add them to this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant