[OpenMP][libomp] Remove false positive for memory sanitizer
authorJonathan Peyton <jonathan.l.peyton@intel.com>
Mon, 6 Feb 2023 15:26:44 +0000 (09:26 -0600)
committerJonathan Peyton <jonathan.l.peyton@intel.com>
Mon, 6 Feb 2023 15:30:21 +0000 (09:30 -0600)
commit402981ee25fe135d63226a7de17dbb14c437c71b
tree0d14839b4b2f3619342598da5fe067ffdbf6c1f9
parente4022b6b87bdf1ceb7f88fe6fdb0edfa7d225f64
[OpenMP][libomp] Remove false positive for memory sanitizer

The memory sanitizer intercepts the memcpy() call but not the direct
assignment of last byte to 0. This leads the sanitizer to believe the
last byte of a string based on the kmp_str_buf_t type is uninitialized.
Hence, the eventual strlen() inside __kmp_env_dump() leads to an
use-of-uninitialized-value warning.

Using strncat() instead gives the sanitizer the information it needs.

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

Fixes #60501
openmp/runtime/src/kmp_safe_c_api.h
openmp/runtime/src/kmp_str.cpp