Skip to content

Commit

Permalink
[MSan] "Fix" use-after-dtor in InitializationState.InitializationState
Browse files Browse the repository at this point in the history
Since the test is specifically trying to exercise UB by testing the
state of an object it is already destroyed, unpoison the memory to
suppress MSan errors.

Bug: 40222690
Change-Id: I840e944f5e8b39668ac05d8d641fdd5f2e3db5ac
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5716150
Reviewed-by: Mark Mentovai <[email protected]>
  • Loading branch information
zetafunction authored and markmentovai committed Jul 17, 2024
1 parent a1fc5d7 commit aef7de4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions util/misc/initialization_state_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <memory>

#include "base/compiler_specific.h"
#include "base/memory/free_deleter.h"
#include "gtest/gtest.h"

Expand Down Expand Up @@ -59,6 +60,10 @@ TEST(InitializationState, InitializationState) {
// buffer that’s still valid and its destructor was called directly, this
// approximates use-after-free without risking that the memory formerly used
// for the InitializationState object has been repurposed.

// (Though this is still UB and MSan does not like this)
MSAN_UNPOISON(initialization_state, sizeof(*initialization_state));

EXPECT_FALSE(initialization_state->is_uninitialized());
EXPECT_FALSE(initialization_state->is_valid());
}
Expand Down

0 comments on commit aef7de4

Please sign in to comment.