From 5044f0a181940c05969fd45aaccd8ce21c03335f Mon Sep 17 00:00:00 2001 From: FritzFlorian Date: Thu, 6 Jun 2019 12:08:55 +0200 Subject: [PATCH] Fix: test that invalidly referenced stack memory. --- lib/pls/src/internal/scheduling/task.cpp | 14 ++++++-------- test/scheduling_tests.cpp | 3 +++ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/pls/src/internal/scheduling/task.cpp b/lib/pls/src/internal/scheduling/task.cpp index 7c06bc7..5a4b1f4 100644 --- a/lib/pls/src/internal/scheduling/task.cpp +++ b/lib/pls/src/internal/scheduling/task.cpp @@ -19,17 +19,15 @@ task::task(const task &other) : deque_state_{other.deque_state_} {} void task::execute() { - { - PROFILE_WORK_BLOCK("execute task") - auto last_executing = thread_state::get()->current_task_; - thread_state::get()->current_task_ = this; + PROFILE_WORK_BLOCK("execute task") + auto last_executing = thread_state::get()->current_task_; + thread_state::get()->current_task_ = this; - execute_internal(); - - thread_state::get()->current_task_ = last_executing; - } + execute_internal(); + PROFILE_END_BLOCK wait_for_all(); + thread_state::get()->current_task_ = last_executing; if (parent_ != nullptr) { parent_->ref_count_--; diff --git a/test/scheduling_tests.cpp b/test/scheduling_tests.cpp index d99be04..710fc80 100644 --- a/test/scheduling_tests.cpp +++ b/test/scheduling_tests.cpp @@ -70,6 +70,9 @@ TEST_CASE("tbb task are scheduled correctly", "[internal/scheduling/fork_join_ta std::atomic dummy_parent{1}, overall_counter{8}; force_steal_sub_task sub_task{&dummy_parent, &overall_counter}; scheduler::spawn_child(sub_task); + + // Required, as child operates on our stack's memory!!! + scheduler::wait_for_all(); }); my_scheduler.terminate(true); } -- libgit2 0.26.0