empiredan opened a new pull request, #1074: URL: https://github.com/apache/incubator-pegasus/pull/1074
This PR is to resolve the issue https://github.com/apache/incubator-pegasus/issues/1066. The root cause of issue https://github.com/apache/incubator-pegasus/issues/1066 is that the percentile is freed during the destruction of the metric registry, after which sometimes the handler for asynchronous wait operation of timer will be still executed, where the freed percentile is certainly referenced. This will lead to heap-use-after-free error. The solution for this problem will be extend the lifetime of percentile: during the construction of the percentile, it can increment its ref count (its base class is `ref_counter`) since it is referenced by timer. This effectively extends the lifetime of percentile: even if both of its metric entity and registry are destructed, it can still survive in the memory for the reason that its ref count is 1 at least. Once the percentile should be released when it will retire from metric entity or the metric registry (singleton) will be destructed, the `close()` method for percentile will be invoked. `close()` will change the state of timer from *running* to *closing*, and also call `cancel()` for the timer. Then, whether the timer is cancelled successfully or not, the timer will finally be stopped: if successful, the callback for cancel will be executed immediately; otherwise, the *closing* state will tell the timer to stop finally, albeit sometimes after a while. -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
