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

ASF GitHub Bot commented on PARQUET-1265:
-----------------------------------------

pitrou commented on issue #452: PARQUET-1265: Segfault on static 
ApplicationVersion initialization
URL: https://github.com/apache/parquet-cpp/pull/452#issuecomment-380471761
 
 
   Another solution is to avoid using a regex for parsing a well-known version:
   ```diff
   diff --git a/src/parquet/metadata.cc b/src/parquet/metadata.cc
   index 91304cf..c3c9809 100644
   --- a/src/parquet/metadata.cc
   +++ b/src/parquet/metadata.cc
   @@ -32,11 +32,11 @@
    namespace parquet {
    
    const ApplicationVersion ApplicationVersion::PARQUET_251_FIXED_VERSION =
   -    ApplicationVersion("parquet-mr version 1.8.0");
   +    ApplicationVersion("parquet-mr", 1, 8, 0);
    const ApplicationVersion ApplicationVersion::PARQUET_816_FIXED_VERSION =
   -    ApplicationVersion("parquet-mr version 1.2.9");
   +    ApplicationVersion("parquet-mr", 1, 2, 9);
    const ApplicationVersion 
ApplicationVersion::PARQUET_CPP_FIXED_STATS_VERSION =
   -    ApplicationVersion("parquet-cpp version 1.3.0");
   +    ApplicationVersion("parquet-cpp", 1, 3, 0);
    
    template <typename DType>
    static std::shared_ptr<RowGroupStatistics> MakeTypedColumnStats(
   @@ -448,6 +448,10 @@ std::shared_ptr<const KeyValueMetadata> 
FileMetaData::key_value_metadata() const
    
    void FileMetaData::WriteTo(OutputStream* dst) { return impl_->WriteTo(dst); 
}
    
   +ApplicationVersion::ApplicationVersion(const std::string& application, int 
major,
   +                                       int minor, int patch)
   +    : application_(application), version{major, minor, patch} {}
   +
    ApplicationVersion::ApplicationVersion(const std::string& created_by) {
      boost::regex app_regex{ApplicationVersion::APPLICATION_FORMAT};
      boost::regex ver_regex{ApplicationVersion::VERSION_FORMAT};
   diff --git a/src/parquet/metadata.h b/src/parquet/metadata.h
   index 7850358..4223014 100644
   --- a/src/parquet/metadata.h
   +++ b/src/parquet/metadata.h
   @@ -74,6 +74,7 @@ class ApplicationVersion {
    
      ApplicationVersion() {}
      explicit ApplicationVersion(const std::string& created_by);
   +  ApplicationVersion(const std::string& application, int major, int minor, 
int patch);
    
      // Returns true if version is strictly less than other_version
      bool VersionLt(const ApplicationVersion& other_version) const;
   ```
   
   (the advantage here is that it doesn't break the API)

----------------------------------------------------------------
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


> Segfault on static ApplicationVersion initialization
> ----------------------------------------------------
>
>                 Key: PARQUET-1265
>                 URL: https://issues.apache.org/jira/browse/PARQUET-1265
>             Project: Parquet
>          Issue Type: Bug
>          Components: parquet-cpp
>    Affects Versions: cpp-1.4.0
>            Reporter: Lawrence Chan
>            Assignee: Deepak Majeti
>            Priority: Major
>
> I'm seeing a segfault when I link/run with a shared libparquet.so with 
> statically linked boost. Given the backtrace, it seems that this is due to 
> the static ApplicationVersion constants, likely due to some static 
> initialization order issue. The problem goes away if I turn those static vars 
> into static funcs returning function-local statics.
> Backtrace:
> {code}
> #0  0x00007ffff753cf8b in std::basic_string<char, std::char_traits<char>, 
> std::allocator<char> >::basic_string(std::string const&) () from 
> /lib64/libstdc++.so.6
> #1  0x00007ffff7aeae9c in 
> boost::re_detail_106600::cpp_regex_traits_char_layer<char>::init() () from 
> debug/libparquet.so.1
> #2  0x00007ffff7adcc2b in 
> boost::object_cache<boost::re_detail_106600::cpp_regex_traits_base<char>, 
> boost::re_detail_106600::cpp_regex_traits_implementation<char> 
> >::do_get(boost::re_detail_106600::cpp_regex_traits_base<char> const&, 
> unsigned long) () from debug/libparquet.so.1
> #3  0x00007ffff7ae9023 in boost::basic_regex<char, boost::regex_traits<char, 
> boost::cpp_regex_traits<char> > >::do_assign(char const*, char const*, 
> unsigned int) () from debug/libparquet.so.1
> #4  0x00007ffff7a5ed98 in boost::basic_regex<char, boost::regex_traits<char, 
> boost::cpp_regex_traits<char> > >::assign (this=0x7fffffff5580, 
> p1=0x7ffff7af66d8 
> "(.*?)\\s*(?:(version\\s*(?:([^(]*?)\\s*(?:\\(\\s*build\\s*([^)]*?)\\s*\\))?)?)?)",
>  p2=0x7ffff7af6720 "", f=0) at 
> /tmp/boost-1.66.0/include/boost/regex/v4/basic_regex.hpp:381
> #5  0x00007ffff7a5b653 in boost::basic_regex<char, boost::regex_traits<char, 
> boost::cpp_regex_traits<char> > >::assign (this=0x7fffffff5580, 
> p=0x7ffff7af66d8 
> "(.*?)\\s*(?:(version\\s*(?:([^(]*?)\\s*(?:\\(\\s*build\\s*([^)]*?)\\s*\\))?)?)?)",
>  f=0) at /tmp/boost-1.66.0/include/boost/regex/v4/basic_regex.hpp:366
> #6  0x00007ffff7a57049 in boost::basic_regex<char, boost::regex_traits<char, 
> boost::cpp_regex_traits<char> > >::basic_regex (this=0x7fffffff5580, 
> p=0x7ffff7af66d8 
> "(.*?)\\s*(?:(version\\s*(?:([^(]*?)\\s*(?:\\(\\s*build\\s*([^)]*?)\\s*\\))?)?)?)",
>  f=0) at /tmp/boost-1.66.0/include/boost/regex/v4/basic_regex.hpp:335
> #7  0x00007ffff7a4fa1f in parquet::ApplicationVersion::ApplicationVersion 
> (this=0x7ffff7ddbfc0 
> <parquet::ApplicationVersion::PARQUET_251_FIXED_VERSION>, 
> created_by="parquet-mr version 1.8.0") at 
> /tmp/parquet-cpp-apache-parquet-cpp-1.4.0/src/parquet/metadata.cc:477
> #8  0x00007ffff7a516c5 in __static_initialization_and_destruction_0 
> (__initialize_p=1, __priority=65535) at 
> /tmp/parquet-cpp-apache-parquet-cpp-1.4.0/src/parquet/metadata.cc:58
> #9  0x00007ffff7a5179e in _GLOBAL__sub_I_metadata.cc(void) () at 
> /tmp/parquet-cpp-apache-parquet-cpp-1.4.0/src/parquet/metadata.cc:913
> #10 0x00007ffff7dec1e3 in _dl_init_internal () from 
> /lib64/ld-linux-x86-64.so.2
> #11 0x00007ffff7dde21a in _dl_start_user () from /lib64/ld-linux-x86-64.so.2
> #12 0x0000000000000001 in ?? ()
> #13 0x00007fffffff5ff5 in ?? ()
> #14 0x0000000000000000 in ?? ()
> {code}
> Versions:
> - gcc-4.8.5
> - boost-1.66.0
> - parquet-cpp-1.4.0



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

Reply via email to