[Openmp-commits] [PATCH] D52046: [OMPT] Fix unsafe initialization of ompt_data_t objects.

Hansang Bae via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Thu Sep 13 09:53:39 PDT 2018


hbae created this revision.
hbae added reviewers: AndreyChurbanov, tlwilmar, jlpeyton.
hbae added a project: OpenMP.

Initializing an `ompt_data_t` object using the pointer union member is potentially unsafe in 32-bit programs.
This change fixes the issue by using the constant, `ompt_data_none`.


Repository:
  rOMP OpenMP

https://reviews.llvm.org/D52046

Files:
  runtime/src/kmp_runtime.cpp


Index: runtime/src/kmp_runtime.cpp
===================================================================
--- runtime/src/kmp_runtime.cpp
+++ runtime/src/kmp_runtime.cpp
@@ -1209,8 +1209,7 @@
 #endif /* OMP_40_ENABLED */
 
 #if OMPT_SUPPORT
-  ompt_data_t ompt_parallel_data;
-  ompt_parallel_data.ptr = NULL;
+  ompt_data_t ompt_parallel_data = ompt_data_none;
   ompt_data_t *implicit_task_data;
   void *codeptr = OMPT_LOAD_RETURN_ADDRESS(global_tid);
   if (ompt_enabled.enabled &&
@@ -1477,8 +1476,7 @@
     master_set_numthreads = master_th->th.th_set_nproc;
 
 #if OMPT_SUPPORT
-    ompt_data_t ompt_parallel_data;
-    ompt_parallel_data.ptr = NULL;
+    ompt_data_t ompt_parallel_data = ompt_data_none;
     ompt_data_t *parent_task_data;
     omp_frame_t *ompt_frame;
     ompt_data_t *implicit_task_data;
@@ -3726,7 +3724,7 @@
     }
     root_thread->th.th_info.ds.ds_gtid = gtid;
 #if OMPT_SUPPORT
-    root_thread->th.ompt_thread_info.thread_data.ptr = NULL;
+    root_thread->th.ompt_thread_info.thread_data = ompt_data_none;
 #endif
     root_thread->th.th_root = root;
     if (__kmp_env_consistency_check) {
@@ -5601,7 +5599,7 @@
   ompt_data_t *thread_data;
   if (ompt_enabled.enabled) {
     thread_data = &(this_thr->th.ompt_thread_info.thread_data);
-    thread_data->ptr = NULL;
+    *thread_data = ompt_data_none;
 
     this_thr->th.ompt_thread_info.state = omp_state_overhead;
     this_thr->th.ompt_thread_info.wait_id = 0;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52046.165315.patch
Type: text/x-patch
Size: 1449 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20180913/923417c1/attachment.bin>


More information about the Openmp-commits mailing list