Skip to content
This repository has been archived by the owner on Jul 3, 2024. It is now read-only.

[Issue #70] Warn about the use of release on std::unique_ptr #79

Open
wants to merge 2 commits into
base: lifetime
Choose a base branch
from

Conversation

lklein53
Copy link
Collaborator

Currently only the detection is implemented. Wasn't sure about the warning policy. The new warning doesn't really seem to fit for the LifetimeReporter

@lklein53 lklein53 requested a review from mgehre November 11, 2019 21:59
explicit unique_ptr(T *t);
T *release();
};
// A random class that models a private key.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove unrelated information? Same for all mentions of PrivateKey

@@ -633,6 +633,16 @@ class PSetsBuilder : public ConstStmtVisitor<PSetsBuilder, void> {
if (!Callee)
return;

if (auto MCE = dyn_cast<CXXMemberCallExpr>(CallE)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good for getting rid of the false positive but in the future I think it would be great to:

  • Update the state, so we know what is the pointee of the returned ptr (*uniqueptr in our case).
  • Set the unique_ptr to null. I am not sure if we support nullable owners properly at the point. The current paper also does not really elaborate on this.
  • Maybe we need a way to annotate ownership transferring functions in the future? Not all of them migh have the name release.

Some of these notes are more for our future selves designing a new version of the analysis, rather than the current implementation :)

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

Successfully merging this pull request may close these issues.

3 participants