Fix issues reported by ASAN (#3671)
This commit is contained in:
@@ -70,6 +70,10 @@ add_library(
|
||||
|
||||
set(UBSAN_BLACKLIST ${PROJECT_SOURCE_DIR}/scripts/ubsan.blacklist)
|
||||
|
||||
if (MLN_WITH_SANITIZER)
|
||||
message(STATUS "MLN_WITH_SANITIZER is enabled, using \"${MLN_WITH_SANITIZER}\" sanitizer")
|
||||
endif()
|
||||
|
||||
target_compile_options(
|
||||
mbgl-compiler-options
|
||||
INTERFACE
|
||||
|
||||
@@ -69,7 +69,7 @@ TEST(MainResourceLoader, TEST_REQUIRES_SERVER(VolatileStoragePolicy)) {
|
||||
|
||||
// Volatile resources are not stored in cache,
|
||||
// so we always get new data from the server ("Response N+1").
|
||||
req = fs.request(resource, [&](Response res2) {
|
||||
req = fs.request(resource, [&, firstData](Response res2) {
|
||||
req.reset();
|
||||
EXPECT_EQ(nullptr, res2.error);
|
||||
ASSERT_TRUE(res2.data);
|
||||
|
||||
@@ -366,18 +366,21 @@ TEST(Thread, PoolWaitAdd) {
|
||||
auto seq = Scheduler::GetSequenced();
|
||||
|
||||
// add new tasks every few milliseconds
|
||||
std::atomic<bool> addActive{true};
|
||||
std::atomic<int> added{0};
|
||||
std::atomic<int> executed{0};
|
||||
seq->schedule([&] {
|
||||
while (addActive) {
|
||||
pool->schedule([&] { executed++; });
|
||||
added++;
|
||||
struct State {
|
||||
std::atomic<bool> addActive{true};
|
||||
std::atomic<int> added{0};
|
||||
std::atomic<int> executed{0};
|
||||
};
|
||||
auto state = std::make_shared<State>();
|
||||
seq->schedule([pool, state] {
|
||||
while (state->addActive) {
|
||||
pool->schedule([state] { state->executed++; });
|
||||
state->added++;
|
||||
}
|
||||
});
|
||||
|
||||
// Wait be sure some are added
|
||||
while (added < 1) {
|
||||
while (state->added < 1) {
|
||||
std::this_thread::sleep_for(Milliseconds(10));
|
||||
}
|
||||
|
||||
@@ -387,8 +390,10 @@ TEST(Thread, PoolWaitAdd) {
|
||||
|
||||
pool->waitForEmpty();
|
||||
|
||||
addActive = false;
|
||||
state->addActive = false;
|
||||
pool->waitForEmpty();
|
||||
|
||||
ASSERT_GE(state->added.load(), 1);
|
||||
}
|
||||
|
||||
TEST(Thread, PoolWaitException) {
|
||||
|
||||
Reference in New Issue
Block a user