[Mvapich-discuss] OMB: Patch for Memory leak in validate_data

Robison, Luke lrbison at amazon.com
Tue Jun 6 15:04:55 EDT 2023


!-------------------------------------------------------------------|
  This Message Is From an External Sender
  This message came from outside your organization.
|-------------------------------------------------------------------!

Hello,

My team has found an issue with the validate_data() function in osu-micro-benchmarks.  Initially it was presented as a crash during the execution of osu_multi_lat, but we find it may affect more tests than just that one.  The problem is that "expected_buffer" is not freed during validation, and eventually memory leaks exhaust system memory.

The patch is below.  Please consider crediting Shi Jin for this fix.  The patch was generated originally on 7.0.1, but found to also be present in 7.1.1.

Thank you,
Luke Robison
Amazon AWS

---

Author: Shi Jin <sjina at amazon.com>
Date:   Fri Jun 2 22:35:05 2023 +0000

    c/util: Fix a memory leak in validate_data()

    In validate_data(), expected_buffer is not freed
    after being malloced, which causes a memory leak
    and could make the benchmark crash due to out of
    memory. This patch fixes this issue.

diff --git a/c/util/osu_util_mpi.c b/c/util/osu_util_mpi.c
index 99243b7..2e98272 100644
--- a/c/util/osu_util_mpi.c
+++ b/c/util/osu_util_mpi.c
@@ -1766,8 +1766,10 @@ uint8_t validate_data(void* r_buf, size_t size, int num_procs,
                 } elseif if (memcmp(temp_char_r_buf, expected_buffer, num_elements)) {
                     free(temp_r_buf);
+                    free(expected_buffer);
                     return 1;
                 }
                 free(temp_r_buf);
+                free(expected_buffer);
                 return 0;
             }
             break;



More information about the Mvapich-discuss mailing list