[Openmp-commits] [PATCH] D95167: [OpenMP] properly initialize buckets in __kmp_dephash_extend

Joseph Schuchart via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Thu Jan 21 13:13:39 PST 2021


jschuchart created this revision.
jschuchart added reviewers: mprobst, AndreyChurbanov.
jschuchart added a project: OpenMP.
Herald added subscribers: guansong, yaxunl.
jschuchart requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: openmp-commits, sstefan1.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D95167

Files:
  openmp/runtime/src/kmp_taskdeps.cpp


Index: openmp/runtime/src/kmp_taskdeps.cpp
===================================================================
--- openmp/runtime/src/kmp_taskdeps.cpp
+++ openmp/runtime/src/kmp_taskdeps.cpp
@@ -86,6 +86,12 @@
   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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95167.318294.patch
Type: text/x-patch
Size: 575 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20210121/d2e0e2ba/attachment.bin>


More information about the Openmp-commits mailing list