[Openmp-commits] [openmp] edbcc17 - [OpenMP] libomp: properly initialize buckets in __kmp_dephash_extend

via Openmp-commits openmp-commits at lists.llvm.org
Fri Jan 22 09:30:50 PST 2021


Author: Joseph Schuchart
Date: 2021-01-22T20:29:46+03:00
New Revision: edbcc17b7a0b5a4f20ec55983e172d0120ccbca9

URL: https://github.com/llvm/llvm-project/commit/edbcc17b7a0b5a4f20ec55983e172d0120ccbca9
DIFF: https://github.com/llvm/llvm-project/commit/edbcc17b7a0b5a4f20ec55983e172d0120ccbca9.diff

LOG: [OpenMP] libomp: properly initialize buckets in __kmp_dephash_extend

The buckets are initialized in __kmp_dephash_create but when they are extended
the memory is allocated but not NULL'd, potentially leaving some buckets
uninitialized after all entries have been copied into the new allocation.
This commit makes sure the buckets are properly initialized with NULL before
copying the entries.

Differential Revision: https://reviews.llvm.org/D95167

Added: 
    

Modified: 
    openmp/runtime/src/kmp_taskdeps.cpp

Removed: 
    


################################################################################
diff  --git a/openmp/runtime/src/kmp_taskdeps.cpp b/openmp/runtime/src/kmp_taskdeps.cpp
index 7a804d1171db..f580431d0182 100644
--- a/openmp/runtime/src/kmp_taskdeps.cpp
+++ b/openmp/runtime/src/kmp_taskdeps.cpp
@@ -86,6 +86,12 @@ static kmp_dephash_t *__kmp_dephash_extend(kmp_info_t *thread,
   h->buckets = (kmp_dephash_entry **)(h + 1);
   h->generation = gen;
   h->nconflicts = 0;
+
+  // make sure buckets are properly initialized
+  for (size_t i = 0; i < new_size; i++) {
+    h->buckets[i] = NULL;
+  }
+
   // insert existing elements in the new table
   for (size_t i = 0; i < current_dephash->size; i++) {
     kmp_dephash_entry_t *next, *entry;


        


More information about the Openmp-commits mailing list