[ 
https://issues.apache.org/jira/browse/ARROW-2359?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16419917#comment-16419917
 ] 

ASF GitHub Bot commented on ARROW-2359:
---------------------------------------

wesm closed pull request #1800: ARROW-2359: [C++] do not use static shared_ptr 
in TYPE_FACTORY to make it thread safe
URL: https://github.com/apache/arrow/pull/1800
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/cpp/src/arrow/type.cc b/cpp/src/arrow/type.cc
index 792d1bfd0..cde4002a0 100644
--- a/cpp/src/arrow/type.cc
+++ b/cpp/src/arrow/type.cc
@@ -369,8 +369,7 @@ ACCEPT_VISITOR(DictionaryType);
 
 #define TYPE_FACTORY(NAME, KLASS)                                        \
   std::shared_ptr<DataType> NAME() {                                     \
-    static std::shared_ptr<DataType> result = std::make_shared<KLASS>(); \
-    return result;                                                       \
+    return std::make_shared<KLASS>();                                    \
   }
 
 TYPE_FACTORY(null, NullType);


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> [C++] Type objects produced by DataType factory are not thread safe
> -------------------------------------------------------------------
>
>                 Key: ARROW-2359
>                 URL: https://issues.apache.org/jira/browse/ARROW-2359
>             Project: Apache Arrow
>          Issue Type: Task
>          Components: C++
>            Reporter: Anton Shmigirilov
>            Assignee: Antoine Pitrou
>            Priority: Minor
>              Labels: pull-request-available
>
> TYPE_FACTORY() macro that produces type shortcuts (boolean(), int32(), utf8() 
> and so on) uses static shared_ptr inside. There are race conditions possible 
> against shared_ptr's reference counter.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to