MCPcopy Create free account
hub / github.com/apache/impala / TEST

Function TEST

be/src/runtime/runtime-state-test.cc:36–62  ·  view source on GitHub ↗

Regression test for IMPALA-8270: MemTracker teardown order leading to use-after-free from LogUsage.

Source from the content-addressed store, hash-verified

34// Regression test for IMPALA-8270: MemTracker teardown order leading to
35// use-after-free from LogUsage.
36TEST(RuntimeStateTest, MemTrackerTeardown) {
37 const int LOG_USAGE_THREADS = 4;
38 const int CONSTRUCT_ITERS = 10;
39 TestEnv test_env;
40 ASSERT_OK(test_env.Init());
41 // Poll LogUsage() from other threads to reproduce race.
42 AtomicBool stop_threads(false);
43 thread_group log_usage_threads;
44 for (int i = 0; i < LOG_USAGE_THREADS; ++i) {
45 log_usage_threads.add_thread(new thread([&test_env, &stop_threads]() {
46 while (!stop_threads.Load()) {
47 string usage = test_env.exec_env()->process_mem_tracker()->LogUsage(100);
48 }
49 }));
50 }
51
52 // Construct and tear down RuntimeState repeatedly to try to reproduce race.
53 for (int i = 0; i < CONSTRUCT_ITERS; ++i) {
54 TQueryCtx query_ctx;
55 unique_ptr<RuntimeState> state(new RuntimeState(query_ctx, test_env.exec_env()));
56 ASSERT_TRUE(state->instance_mem_tracker() != nullptr);
57 state->ReleaseResources();
58 state.reset();
59 }
60 stop_threads.Store(true);
61 log_usage_threads.join_all();
62}
63}
64
65int main(int argc, char** argv) {

Callers

nothing calls this directly

Calls 9

LogUsageMethod · 0.80
exec_envMethod · 0.80
instance_mem_trackerMethod · 0.80
resetMethod · 0.65
InitMethod · 0.45
LoadMethod · 0.45
process_mem_trackerMethod · 0.45
ReleaseResourcesMethod · 0.45
StoreMethod · 0.45

Tested by

no test coverage detected