Skip to content

C++: Fix false positives for cpp/resource-not-released-in-destructor - #22764

Open
geoffw0 wants to merge 3 commits into
github:mainfrom
geoffw0:destructorrelease
Open

geoffw0 wants to merge 3 commits into
github:mainfrom
geoffw0:destructorrelease

Conversation

@geoffw0

@geoffw0 geoffw0 commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Fix false positives for cpp/resource-not-released-in-destructor, using global value numbering.

This is largely Copilot's work. I have reviewed and tested with MRVA. I will be checking performance with DCA, as that can be an issue with GVN, though in this case GVN was already present in one of the other branches so I am optimistic.

@geoffw0
geoffw0 requested a review from a team as a code owner October 6, 2026 16:49
Copilot AI balanced review requested due to automatic review settings October 6, 2026 16:49
@geoffw0 geoffw0 added the C++ label Oct 6, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🔵 Needs a closer look

The expanded global value numbering match still awaits the planned performance validation.

Review effort: Balanced
Findings: None

What changed in this PR

Reduces false positives in C++ destructor resource-release analysis by recognizing resources released through local aliases.

Changes:

  • Uses global value numbering to match released expressions.
  • Adds alias regression tests, including an overwritten alias that must still trigger an alert.
  • Updates expectations and documents the improvement.
File Description
cpp/​ql/​test/​query-tests/​jsf/​4.10 Classes/​AV Rule 79/​TemplateDestructor.cpp Adds template, non-template, and overwritten-alias tests.
cpp/​ql/​test/​query-tests/​jsf/​4.10 Classes/​AV Rule 79/​ListDelete.cpp Removes the false-positive annotation from a test comment.
cpp/​ql/​test/​query-tests/​jsf/​4.10 Classes/​AV Rule 79/​AV Rule 79.expected Updates expected alerts.
cpp/​ql/​src/​jsf/​4.10 Classes/​AV Rule 79.ql Matches releases through value-equivalent expressions.
cpp/​ql/​src/​change-notes/​2026-10-06-resource-release-aliases.md Documents reduced false positives.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@geoffw0

geoffw0 commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

DCA looks good to me (i.e. there is no sign of any performance problem).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants