You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2021/01/09 04:31:59 UTC

[GitHub] [incubator-doris] stdpain opened a new pull request #5214: [BUG] fix be exit core when background thread access heap-after-free

stdpain opened a new pull request #5214:
URL: https://github.com/apache/incubator-doris/pull/5214


   ## Proposed changes
   
   will close #5213 
   
   ## Types of changes
   
   What types of changes does your code introduce to Doris?
   _Put an `x` in the boxes that apply_
   
   - [x] Bugfix (non-breaking change which fixes an issue)
   - [] New feature (non-breaking change which adds functionality)
   - [] Breaking change (fix or feature that would cause existing functionality to not work as expected)
   - [] Documentation Update (if none of the other choices apply)
   - [x] Code refactor (Modify the code structure, format the code, etc...)
   
   ## Checklist
   
   _Put an `x` in 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._
   
   - [x] I have create an issue on (Fix #ISSUE), and have described the bug/feature there in detail
   - [x] Compiling and unit tests pass locally with my changes
   - [x] I have added tests that prove my fix is effective or that my feature works
   - [] If this change need a document change, I have updated the document
   - [x] Any dependent changes have been merged
   
   I have use shared_ptr to solve the problem of release dependency
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] HappenLee commented on a change in pull request #5214: [BUG] fix be exit core when background thread access heap-after-free

Posted by GitBox <gi...@apache.org>.
HappenLee commented on a change in pull request #5214:
URL: https://github.com/apache/incubator-doris/pull/5214#discussion_r554584621



##########
File path: be/src/olap/olap_server.cpp
##########
@@ -39,23 +39,28 @@ namespace doris {
 // number of running SCHEMA-CHANGE threads
 volatile uint32_t g_schema_change_active_threads = 0;
 
+// 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
 Status StorageEngine::start_bg_threads() {
     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(); },

Review comment:
       Maybe we should not pass this, but the shared_ptr of storage engine




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] acelyc111 commented on a change in pull request #5214: [BUG] fix be exit core when background thread access heap-after-free

Posted by GitBox <gi...@apache.org>.
acelyc111 commented on a change in pull request #5214:
URL: https://github.com/apache/incubator-doris/pull/5214#discussion_r554663569



##########
File path: be/src/olap/olap_server.cpp
##########
@@ -39,23 +39,28 @@ namespace doris {
 // number of running SCHEMA-CHANGE threads
 volatile uint32_t g_schema_change_active_threads = 0;
 
+// 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

Review comment:
       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.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] stdpain closed pull request #5214: [BUG] fix be exit core when background thread access heap-after-free

Posted by GitBox <gi...@apache.org>.
stdpain closed pull request #5214:
URL: https://github.com/apache/incubator-doris/pull/5214


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [incubator-doris] HappenLee commented on a change in pull request #5214: [BUG] fix be exit core when background thread access heap-after-free

Posted by GitBox <gi...@apache.org>.
HappenLee commented on a change in pull request #5214:
URL: https://github.com/apache/incubator-doris/pull/5214#discussion_r554585086



##########
File path: be/src/util/doris_metrics.h
##########
@@ -207,11 +209,17 @@ class DorisMetrics {
     static const std::string _s_registry_name;
     static const std::string _s_hook_name;
 
+    // used for hold a reference count from CoreLocalValueController
+    // we should make sure that DorisMetrics is released after CoreLocalValueController
+    std::shared_ptr<CoreLocalValueController<int64_t>> _int64_counter_ref = CoreLocalValueController<int64_t>::reference();
+    std::shared_ptr<CoreLocalValueController<uint64_t>> _uint64_counter_ref = CoreLocalValueController<uint64_t>::reference();
+
     MetricRegistry _metric_registry;
 
     std::unique_ptr<SystemMetrics> _system_metrics;
 
     std::shared_ptr<MetricEntity> _server_metric_entity;
+

Review comment:
       no need add necessary space




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org