-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[BUG] fix be exit core when background thread access heap-after-free #5214
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
Conversation
| RETURN_IF_ERROR(Thread::create( | ||
| "StorageEngine", "unused_rowset_monitor_thread", | ||
| [this]() { this->_unused_rowset_monitor_thread_callback(); }, | ||
| [this]() { this->shared_from_this()->_unused_rowset_monitor_thread_callback(); }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should not pass this, but the shared_ptr of storage engine
| std::unique_ptr<SystemMetrics> _system_metrics; | ||
|
|
||
| std::shared_ptr<MetricEntity> _server_metric_entity; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need add necessary space
HappenLee
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some tiny code may need change
|
|
||
| // background threads is detached thread, but they will depend on 'this' pointer. | ||
| // so we should pass a shared_from_this ptr to make sure that the pointer is not destroyed | ||
| // before the thread exits |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion, we should ensure all threads stoped before destrory the StorageEngine instance, use smart pointer is a compromised way to resolve this problem. There is no reason to keep any thread running after StorageEngine stoped in main function.
…he#55936) (apache#5214) close apache#4875 --------- Co-authored-by: shee <13843187+qzsee@users.noreply.github.com> Co-authored-by: garenshi <garenshi@tencnet.com>
Proposed changes
will close #5213
Types of changes
What types of changes does your code introduce to Doris?
Put an
xin the boxes that applyChecklist
Put an
xin the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.I have use shared_ptr to solve the problem of release dependency