Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

valgrind: fix leaks of task_worker #181

Merged
merged 4 commits into from
Oct 23, 2018
Merged

Conversation

neverchanje
Copy link
Contributor

No description provided.

@neverchanje neverchanje added the area/memcheck PR or issues related to valgrind memcheck label Oct 19, 2018
@@ -61,10 +61,7 @@ task_queue::task_queue(task_worker_pool *pool, int index, task_queue *inner_prov
_spec = (threadpool_spec *)&pool->spec();
}

task_queue::~task_queue()
{
perf_counters::instance().remove_counter(_queue_length_counter->full_name());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这段代码解释下,_queue_length_counter 本身是一个 perf_counter_wrapper,它析构时会调用

    perf_counters::instance().remove_counter(this->full_name());

所以执行顺序是

  1. task_queue 析构
  2. _queue_length_counter 被 removed
  3. _queue_length_counter 析构
  4. _queue_length_counter 又被 removed,这里是第二次 remove,valgrind 报错 invalid read.

@neverchanje neverchanje mentioned this pull request Oct 19, 2018
9 tasks
@neverchanje neverchanje merged commit e6167ce into XiaoMi:master Oct 23, 2018
vagetablechicken pushed a commit to vagetablechicken/rdsn that referenced this pull request Nov 5, 2018
@neverchanje neverchanje deleted the dev3 branch June 1, 2019 09:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/memcheck PR or issues related to valgrind memcheck
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants