Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed: add mutex for cpu_info init() #1942

Closed
wants to merge 1 commit into from

Conversation

GOGOYAO
Copy link
Contributor

@GOGOYAO GOGOYAO commented Oct 9, 2019

Fixed: add mutex for cpu_info init() to prevent random core dump caused by init() in multi threads.

@GOGOYAO GOGOYAO closed this Oct 9, 2019
@GOGOYAO GOGOYAO reopened this Oct 9, 2019
@GOGOYAO GOGOYAO closed this Oct 9, 2019
@GOGOYAO GOGOYAO reopened this Oct 9, 2019
Copy link
Contributor

@imay imay left a comment

Choose a reason for hiding this comment

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

I think you don't find the root cause. You'd better look into it again.

@@ -81,6 +81,7 @@ int CpuInfo::max_num_numa_nodes_;
unique_ptr<int[]> CpuInfo::core_to_numa_node_;
vector<vector<int>> CpuInfo::numa_node_to_cores_;
vector<int> CpuInfo::numa_node_core_idx_;
pthread_mutex_t CpuInfo::init_mutex_;
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. we don't need this lock, because CpuInfo is only initialized in main function.
  2. even if we need a lock, std::mutex is preferred.
  3. you don't call pthread_mutex_init() to initialize this variable, it will lead process crash.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This problem has been fixed in 1826 with same way, in which use a mutex to lock when init(). So I close this now.

@GOGOYAO GOGOYAO closed this Oct 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants