Skip to content
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

[compiler-rt][profile] Fix InstrProfilingFile possible resource leak. #81363

Merged
merged 1 commit into from
Feb 10, 2024

Conversation

devnexen
Copy link
Member

close #79708

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
close llvm#79708
@devnexen devnexen requested a review from petrhosek February 10, 2024 16:12
@llvmbot llvmbot added compiler-rt PGO Profile Guided Optimizations labels Feb 10, 2024
@llvmbot
Copy link
Member

llvmbot commented Feb 10, 2024

@llvm/pr-subscribers-pgo

Author: David CARLIER (devnexen)

Changes

close #79708


Full diff: https://github.com/llvm/llvm-project/pull/81363.diff

1 Files Affected:

  • (modified) compiler-rt/lib/profile/InstrProfilingFile.c (+3)
diff --git a/compiler-rt/lib/profile/InstrProfilingFile.c b/compiler-rt/lib/profile/InstrProfilingFile.c
index 867ae73f0d3b27..f3b457d786e6bd 100644
--- a/compiler-rt/lib/profile/InstrProfilingFile.c
+++ b/compiler-rt/lib/profile/InstrProfilingFile.c
@@ -677,6 +677,7 @@ static void initializeProfileForContinuousMode(void) {
       PROF_ERR("Continuous counter sync mode is enabled, but raw profile is not"
                "page-aligned. CurrentFileOffset = %" PRIu64 ", pagesz = %u.\n",
                (uint64_t)CurrentFileOffset, PageSize);
+      fclose(File);
       return;
     }
     if (writeProfileWithFileObject(Filename, File) != 0) {
@@ -692,6 +693,8 @@ static void initializeProfileForContinuousMode(void) {
 
   if (doMerging()) {
     lprofUnlockFileHandle(File);
+  }
+  if (File != NULL) {
     fclose(File);
   }
 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler-rt PGO Profile Guided Optimizations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

compiler-rt/lib/profile/InstrProfilingFile.c:680:7: error: Resource leak
3 participants