Fix internal assert caused by visiting AST nodes twice.#408
Merged
Conversation
This fixes a compiler crash reported in checkedc/checkedc#221. The checking of bounds information was failling an assertion that bounds are only set once for cast expression nodes. I tracked the problem to an issue in RecursiveASTVisitor.h. It turns out nodes in initializer lists are visited multiple times if they appear in both semantic and syntactic forms of an initializer list. The comment in RecursiveASTVisitor.h about AST nodes being visited exactly once isn't quite accurate. The fix is to borrow an approach used in lib\index\IndexBody.cpp and visit only one form. In our case, we want to visit the semantic form. We'll eventually have more complex checking that ensures that structs are initialized to satisfy their member bounds invariants, and we'll need to use the semantic form for that. Testing: - Added a regression test case to the test\CheckedC directory.
Contributor
|
This works on the vsftpd code that prompted my bug report. |
awruef
approved these changes
Nov 3, 2017
awruef
left a comment
Collaborator
There was a problem hiding this comment.
Owch, I should double check if the converter has the same problem. Looks good to me.
dopelsunce
pushed a commit
to dopelsunce/checkedc-clang
that referenced
this pull request
Sep 28, 2020
sulekhark
pushed a commit
that referenced
this pull request
Jul 8, 2021
* Fix #373 * Use a single constraint variable to represent each typedef * Fix rewriting for array typedefs * Fix rewriting for function typedefs Co-authored-by: Matt McCutchen (Correct Computation) <matt@correctcomputation.com> Co-authored-by: John Kastner <john@correctcomputation.com>
This was referenced Jan 15, 2022
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.
This fixes a compiler crash reported in checkedc/checkedc#221. The checking of bounds information was failling an assertion that bounds are only set once for cast expression nodes. I tracked the problem to an issue in RecursiveASTVisitor.h. It turns out that nodes in initializer lists are visited multiple times if they appear in both semantic and syntactic forms of an initializer list. The comment in RecursiveASTVisitor.h about AST nodes being visited exactly once isn't quite accurate.
The fix is to borrow an approach used in lib\index\IndexBody.cpp and visit only one form. In our case, we want to visit the semantic form. We'll eventually have more complex checking that ensures that structs are initialized to satisfy their member bounds invariants, and we'll need to use the semantic form for that.
Testing: