-
Notifications
You must be signed in to change notification settings - Fork 5
PersistentSourceLocations are ambiguous #18
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
Comments
In certain cases, the file/line/column information stored in the PersistentSourceLocation class is not enough to uniquely disambiguate definitions from one another. To support these cases, this commit adds a "reproducible" AST node identifier as a distinguishing feature. According to the "Clang Front End for LLVM Developers' List": "If you want something that's more stable across runs (pointers would obviously change every time), you can have a look at the getID() method in various AST nodes, which produces an integer that doesn't change across runs but does change across host machines." Which should work fine for our purposes. This fixes #18.
It looks like the fix committed for this (ad94795) is causing regressions. Example:
We hit this, while trying to convert the icecast source from: https://github.com/plum-umd/checkedc-icecast Maybe we should use ids only for functions? Attached is the zip file containing Ref: @hasantouma |
This should address the regression reported by @Machiry and discovered by @hasantouma, and resolve #18.
In certain cases, the file/line/column information stored in the PersistentSourceLocation class is not enough to uniquely disambiguate definitions from one another. To support these cases, this commit adds a "reproducible" AST node identifier as a distinguishing feature. According to the "Clang Front End for LLVM Developers' List": "If you want something that's more stable across runs (pointers would obviously change every time), you can have a look at the getID() method in various AST nodes, which produces an integer that doesn't change across runs but does change across host machines." Which should work fine for our purposes. This fixes #18. (cherry picked from commit ad94795)
This should address the regression reported by @Machiry and discovered by @hasantouma, and resolve #18. (cherry picked from commit 1ff694a)
Cherry-picked from commit 2d090f18a30386e4bb2b8dbfc1e2558d77198f4b Fix the generation of llvm-lit.py so that llvm-lit can be used to run Checked C tests in the Checked C repo from the command line. Several arguments were missing from configure_lit_site_cfg in the CMakeLists.txt file for the checkedc-wrapper directory. This fixes Checked C issue checkedc/checkedc#340. Also fix some warnings about missing tools when running the tests. The tools are clang-specific test executables and tools not used by the Checked C repo tests. Delete them from the list of required tools.
PR #266 improved how we deal with collisions between ambiguous source locations, but the root of the problem still exists. Source locations are still ambiguous. Ideally we can change the PersistentSourceLocation class in the future so that it uniquely identifies a point in the source. |
Are PersistantSourceLocations better understood now? If this is not a specific issue, we can close it or incorporate it into a larger plan to deal with other source location ambiguities. |
@jackastner I think this is now a non-issue? That is, the specific problem that came up with here is now fixed, even though rewriting has other problems? If so, please close. If not, please say what we still need to do. |
The broader issue here is still relevant: a I think this issue can closed, and it should be incorporated into an issue for emitting warnings when 3C can't rewrite a pointer that we think should be checked. |
Projects may use the C preprocessor to achieve polymorphic definitions. For example, consider this macro in safestack.h from OpenSSL:
This causes a problem for how we locate
ConstraintVariables
. We mapPersistentSourceLocations
toConstraintVariables
insideclass ProgramInfo
, but Clang places the spelling location of such definitions inside a scratch space, which can easily lead to namespace collisions. Testing against Icecast on Fedora 29, the following four (completely distinct) functions are associated with<scratch space>:12:1
:int i2d_PKCS7_SIGNED(PKCS7_SIGNED *a, unsigned char **out)
static inline int sk_OPENSSL_CSTRING_unshift(struct stack_st_OPENSSL_CSTRING *sk, const char *ptr) __attribute__((unused))
static inline struct stack_st_void *sk_void_new_null() __attribute__((unused))
void ASN1_IA5STRING_free(ASN1_IA5STRING *a)
Even if the compiler avoided the use of a scratch space for such functions, these collisions would continue to occur in the original file.
The text was updated successfully, but these errors were encountered: