pitrou commented on a change in pull request #12408:
URL: https://github.com/apache/arrow/pull/12408#discussion_r805146753
##########
File path: cpp/src/arrow/util/thread_pool.cc
##########
@@ -144,6 +145,13 @@ struct ThreadPool::State {
// after the ThreadPool is destroyed.
static void WorkerLoop(std::shared_ptr<ThreadPool::State> state,
std::list<std::thread>::iterator it) {
+#ifdef ARROW_WITH_OPENTELEMETRY
+ // The main thread may exit and start shutting down static state before
+ // this thread ends. This means that any calls to OpenTelemetry's static
+ // state will potentially access freed memory. By grabbing a handle we
+ // keep OpenTelemetry's static state alive until this thread ends.
+ internal::tracing::OtHandle handle = internal::tracing::Attach();
Review comment:
This would probably deserve a more general approach. For example:
```c++
class Executor {
public:
class Resource {
public:
virtual ~Resource();
};
// All live executors should keep this object alive
static void KeepAlive(Resource);
};
```
(is it possible to mandate that `Resource` has to be copy-constructible?)
--
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]