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

fix(perf_counter_wrapper): avoid using invalid perf_counters::instance() to remove counter #750

Merged
merged 1 commit into from
Feb 18, 2021

Conversation

zhangyifan27
Copy link
Contributor

The global variable task_spec_profiler *s_spec_profilers could be destroyed after the singleton perf_counters::instance() destroyed,

struct task_spec_profiler
{
    perf_counter_wrapper ptr[PERF_COUNTER_COUNT];
    bool collect_call_count;
    bool is_profile;
    std::atomic<int64_t> *call_counts;

    task_spec_profiler()
    {
        collect_call_count = false;
        is_profile = false;
        call_counts = nullptr;
        memset((void *)ptr, 0, sizeof(ptr));
    }
};

so there would be issues if call perf_counters::instance() in perf_counter_wrapper destructor.

Because it seems not easy to use something else to replace the global variable task_spec_profiler *s_spec_profilers, and make perf_counter_wrapper objects destroyed before perf_counters::instance() destroyed based on current codes, I removed the clear counter operation from perf_counter_wrapper destructor, all counters would be cleared when perf_counters::instance() destroyed.

@zhangyifan27 zhangyifan27 reopened this Feb 5, 2021
@acelyc111 acelyc111 merged commit 6d13c07 into XiaoMi:master Feb 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants