Skip to content

Fix RLC unsoundness with explicit @MustCallUnknown annotation#6994

Open
kelloggm wants to merge 18 commits intotypetools:masterfrom
kelloggm:6990
Open

Fix RLC unsoundness with explicit @MustCallUnknown annotation#6994
kelloggm wants to merge 18 commits intotypetools:masterfrom
kelloggm:6990

Conversation

@kelloggm
Copy link
Contributor

fixes #6990

@kelloggm kelloggm requested a review from mernst March 20, 2025 16:24
mernst
mernst previously approved these changes Mar 20, 2025
Copy link
Member

@mernst mernst left a comment

Choose a reason for hiding this comment

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

Thanks!

@mernst mernst enabled auto-merge (squash) March 20, 2025 16:29
@kelloggm
Copy link
Contributor Author

@mernst I think you should review this again to make sure that the new @MustCall annotations in the Initialization checker are ok.

Also, this change could introduce user-facing behavior in the form of new warnings (as shown by the need to add those annotations). Does that warrant a changelog entry? If so, I don't mind adding one.

@mernst
Copy link
Member

mernst commented Mar 25, 2025

@kelloggm CI is not passing. Could you fix that? Then I will review.

@mernst
Copy link
Member

mernst commented Jul 18, 2025

@kelloggm Ping.

@mernst mernst requested a review from Copilot July 18, 2025 14:35
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request fixes an RLC (Resource Leak Checker) unsoundness issue by adding explicit @MustCallUnknown annotations to prevent incorrect behavior when handling owning parameters with unknown must-call obligations.

  • Adds proper error detection for @Owning parameters with @MustCallUnknown annotations
  • Improves must-call type resolution by using hierarchy-aware annotation lookup
  • Adds type annotations to initialization classes to ensure proper type checking

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
DropOwning.java New test case demonstrating the fix for issue #6990 with expected error
CrashForTempVar.java Adds suppression annotation to focus testing on crash detection
MustCallConsistencyAnalyzer.java Updates annotation lookup logic and fixes typo in comment
InitializationTransfer.java Adds @MustCall type annotations to class declaration
InitializationStore.java Adds @MustCall type annotations and improves class documentation

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 3, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 60f5c7f and 43deefc.

📒 Files selected for processing (11)
  • annotation-file-utilities/src/main/java/org/checkerframework/afu/annotator/Main.java
  • annotation-file-utilities/src/main/java/org/checkerframework/afu/scenelib/el/TypeASTMapper.java
  • annotation-file-utilities/src/main/java/org/checkerframework/afu/scenelib/io/ASTPath.java
  • annotation-file-utilities/src/main/java/org/checkerframework/afu/scenelib/util/SceneOps.java
  • annotation-file-utilities/src/main/java/org/checkerframework/afu/scenelib/util/coll/LinkedHashKeyedSet.java
  • annotation-file-utilities/src/main/java/org/checkerframework/afu/scenelib/util/coll/VivifyingMap.java
  • checker/src/main/java/org/checkerframework/checker/initialization/InitializationStore.java
  • checker/src/main/java/org/checkerframework/checker/initialization/InitializationTransfer.java
  • checker/src/main/java/org/checkerframework/checker/resourceleak/MustCallConsistencyAnalyzer.java
  • checker/tests/ainfer-resourceleak/non-annotated/CrashForTempVar.java
  • checker/tests/resourceleak/DropOwning.java

📝 Walkthrough

Walkthrough

The PR adds @SuppressWarnings("resourceleak:required.method.not.known") annotations to five classes across the annotation-file-utilities module to suppress resource leak warnings. It introduces @MustCall({}) constraints to generic type parameters in InitializationStore, InitializationTransfer, and VivifyingMap to enforce must-call discipline. The MustCallConsistencyAnalyzer is improved with a grammar fix and updated must-call value resolution logic using hierarchy-aware annotation lookup. A new test file is added to verify behavior with @MustCallUnknown annotations.

Possibly related PRs

Suggested reviewers

  • smillst
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR comprehensively addresses issue #6990 by fixing RLC unsoundness through explicit @MustCallUnknown annotation handling and must-call constraint propagation.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing RLC unsoundness with must-call annotations and resource leak handling, with no unrelated modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RLC unsoundness at (pseudo?) assignments to @MustCallUnknown

3 participants