-
Notifications
You must be signed in to change notification settings - Fork 1.7k
CPP: Fix FPs for 'Resource not released in destructor' involving virtual method calls #562
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
Conversation
Without a proper virtual-dispatch library you'll get false negatives in the test if you define a I can probably be persuaded to merge a stub virtual-dispatch library since it'll be better than having nothing at all. I'm wary of adding it to |
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.
How is performance?
e.(FunctionCall).getTarget() = f and | ||
( | ||
e.(FunctionCall).getTarget() = f or | ||
e.(FunctionCall).getTarget().(MemberFunction).getAnOverridingFunction*() = f |
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.
These two *
can be +
, right?
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.
Yes. Done.
I've added some test cases that verify this behaviour.
OK, let's do a proper library at a later date then.
Not too bad:
Note that
due to the |
Remove accidentally added binary
Fixes https://jira.semmle.com/browse/CPP-308. The fix is to account for calls to virtual methods releasing memory via overriding function definitions in derived classes.
@jbj I'm tempted to move the fix into
Function.qll
with the addition of a function:This comes very close to your ideas about a virtual dispatch library, however my solution appears rather trivial (and I'm not completely sure about the last line). How much complexity do you think there would need to be in such a library? What can we do better than the above?