Browse Source

fix(gtest): fix ci error report stack-use-after-scope

how to reproduce the problem:
1: build with asan(revert this MR)
2: then taskset process to one cpu:
taskset 01 ./megbrain_test --gtest_filter=TestAsyncQueue.SynchronizerWaiterStarving

GitOrigin-RevId: eb6f7aa4d8
release-1.10
Megvii Engine Team 3 years ago
parent
commit
80e1f38bea
1 changed files with 8 additions and 1 deletions
  1. +8
    -1
      src/core/test/utils/thread.cpp

+ 8
- 1
src/core/test/utils/thread.cpp View File

@@ -169,9 +169,16 @@ TEST(TestAsyncQueue, SynchronizerMultiProducer3) {
test_scq_sync_multi_producer<100, 100>();
}

//! asan error report stack-use-after-scope when
//! only have one physics cpu or bind to one core
//! with taskset 01 xxx, move processed to global
//! var as a workaround.
namespace {
std::atomic_size_t processed{0};
}
TEST(TestAsyncQueue, SynchronizerWaiterStarving) {
SCQueueSynchronizer sync(0);
std::atomic_size_t processed{0};
processed = 0;
auto worker = [&]() {
while (sync.consumer_fetch(1)) {
for (int volatile i = 0; i < 1000; ++i)


Loading…
Cancel
Save