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
C++: update tests to pick up destructor changes #15329
Conversation
d590000
to
c83a368
Compare
| @@ -1,2 +1,3 @@ | |||
| | exceptions.cpp:25:13:25:19 | ExprStmt | | |||
| | exceptions.cpp:26:13:26:13 | ExprStmt | | |||
| | ms.cpp:38:1:38:1 | c101 | | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume there are now two copies of a destructor call, one reachable one, and one unreachable one, but it's not clear to me what the unreachable one is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question! I'm also wondering why is it considered as a basic block in the first place.
My immediate hypothesis would that the extractor change only uncovers the problem that was not visible before, and not actually causing the problem here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also wondering why is it considered as a basic block in the first place.
I think the naming of the BasicBlocks might be a bit awkward in some cases, so I would not get too hung up on the name.
My immediate hypothesis would that the extractor change only uncovers the problem that was not visible before, and not actually causing the problem here.
Would it be possible to reduce this to some minimal example where we see this changing, so we can have a closer look? I agree that it probably uncovers a problem that was already there, but I would like to understand what the problem was.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll try to reduce it 🙌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reduced it manually to the following case:
// semmle-extractor-options: --microsoft
class C {
public:
~C();
};
void f() {
C c;
__try {
throw 1;
}
__except (1) {}
}The issue is that we generate 3 destructor calls in this case (and 6 variable accesses, 2 per destructor) and some of these variable accesses (not destructor calls themselves) are marked as unreachable.
Marking these var accesses as children of the surrounding scope fixes the issue, but I'm not sure it's the right solution for all cases.
I think I'll file a separate issue to handle this specific issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the reduced test case!
and 6 variable accesses, 2 per destructor
Why two per destructor? There's probably an obvious reason, but I'm not too familiar with the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why two per destructor?
I think I was wrong, there is just one var access per destructor (accessing the variable being destructed).
I filed an issue internally.
c83a368
to
f1049a4
Compare
No description provided.