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

Suppress MemorySanitizer false positive #293

Open
wants to merge 1 commit 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions c/blake3.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
#include "blake3.h"
#include "blake3_impl.h"

#ifdef __has_feature
#if __has_feature(memory_sanitizer)
#include <sanitizer/msan_interface.h>
#define BLAKE3_MEMORY_SANITIZER_BUILD
#endif
#endif

const char *blake3_version(void) { return BLAKE3_VERSION_STRING; }

INLINE void chunk_state_init(blake3_chunk_state *self, const uint32_t key[8],
Expand Down Expand Up @@ -580,6 +587,10 @@ void blake3_hasher_finalize_seek(const blake3_hasher *self, uint64_t seek,
if (self->cv_stack_len == 0) {
output_t output = chunk_state_output(&self->chunk);
output_root_bytes(&output, seek, out, out_len);
#ifdef BLAKE3_MEMORY_SANITIZER_BUILD
// MemorySanitizer gives a false positive due to use of assembly.
__msan_unpoison(out, out_len);
#endif
return;
}
// If there are any bytes in the chunk state, finalize that chunk and do a
Expand Down Expand Up @@ -608,6 +619,10 @@ void blake3_hasher_finalize_seek(const blake3_hasher *self, uint64_t seek,
output = parent_output(parent_block, self->key, self->chunk.flags);
}
output_root_bytes(&output, seek, out, out_len);
#ifdef BLAKE3_MEMORY_SANITIZER_BUILD
// MemorySanitizer gives a false positive due to use of assembly.
__msan_unpoison(out, out_len);
#endif
}

void blake3_hasher_reset(blake3_hasher *self) {
Expand Down