Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MSAN error in rdtime.h #4866

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/rdtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

#if defined(__has_feature)
#if __has_feature(memory_sanitizer)
#include <sanitizer/msan_interface.h>
#endif
#endif


#ifndef _RDTIME_H_
#define _RDTIME_H_

Expand Down Expand Up @@ -209,6 +216,11 @@ static RD_INLINE rd_ts_t rd_timeout_init(int timeout_ms) {
*/
static RD_INLINE void rd_timeout_init_timespec_us(struct timespec *tspec,
rd_ts_t timeout_us) {
#if defined(__has_feature)
#if __has_feature(memory_sanitizer)
__msan_unpoison(tspec, sizeof(*tspec));
#endif
#endif
if (timeout_us == RD_POLL_INFINITE || timeout_us == RD_POLL_NOWAIT) {
tspec->tv_sec = timeout_us;
tspec->tv_nsec = 0;
Expand Down Expand Up @@ -239,6 +251,11 @@ static RD_INLINE void rd_timeout_init_timespec_us(struct timespec *tspec,
*/
static RD_INLINE void rd_timeout_init_timespec(struct timespec *tspec,
int timeout_ms) {
#if defined(__has_feature)
#if __has_feature(memory_sanitizer)
__msan_unpoison(tspec, sizeof(*tspec));
#endif
#endif
if (timeout_ms == RD_POLL_INFINITE || timeout_ms == RD_POLL_NOWAIT) {
tspec->tv_sec = timeout_ms;
tspec->tv_nsec = 0;
Expand Down