Skip to content

Conversation

devnexen
Copy link
Member

close #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