framlog commented on a change in pull request #12358:
URL: https://github.com/apache/arrow/pull/12358#discussion_r801208118
##########
File path: cpp/src/arrow/util/mutex.cc
##########
@@ -50,5 +55,31 @@ Mutex::Guard Mutex::Lock() {
Mutex::Mutex() : impl_(new Impl, [](Impl* impl) { delete impl; }) {}
+#ifndef _WIN32
+namespace {
+
+struct AfterForkState {
+ // A global instance that will also register the atfork handler when
+ // constructed.
+ static AfterForkState instance;
+
+ // The mutex may be used at shutdown, so make it eternal.
+ // The leak (only in child processes) is a small price to pay for robustness.
+ Mutex* mutex = nullptr;
Review comment:
> There isn't a lot of control over shutdown ordering at the moment. So
it's possible the main thread starts tearing down and deleting any unique_ptr
here before the child threads have fully shutdown. Then the child threads might
still try and access this mutex which would lead to accessing freed memory.
I see, thanks.
> Do you have a particular use case in mind?
My intuition is that one may create and destroy the`multiprocessing.Pool`
continuously, which may result in too many leaks here.
--
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]