This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP][libomp] Remove false positive for memory sanitizer
ClosedPublic

Authored by jlpeyton on Feb 6 2023, 7:19 AM.

Details

Summary

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.

Fixes #60501

Diff Detail

Event Timeline

jlpeyton created this revision.Feb 6 2023, 7:19 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 6 2023, 7:19 AM
jlpeyton requested review of this revision.Feb 6 2023, 7:19 AM
jhuber6 accepted this revision.Feb 6 2023, 7:21 AM

LG, thanks for the fix.

This revision is now accepted and ready to land.Feb 6 2023, 7:21 AM

Hi Jonathon,
our amdgpu buildbot seems to have been broken by this patch
https://lab.llvm.org/buildbot/#/builders/193/builds/26173
could you fix quickly? or revert and fix ?

locall reverting patch , resolves buildbot issue.

Ron

i reverted to unblock our bot

jlpeyton updated this revision to Diff 495223.Feb 6 2023, 11:38 AM

Apologies for the breakage!

Update patch to consider that buf.used may be "downsized" without setting a null byte. Hence, buf.str + buf.used may not point to a null-byte. If we insert a null-byte forcefully for __kmp_str_buf_cat[buf]() then the strncat() works as expected as well as preventing false positives from the memory sanitizer.

jlpeyton reopened this revision.Feb 6 2023, 11:49 AM
This revision is now accepted and ready to land.Feb 6 2023, 11:49 AM