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

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

majetideepak closed pull request #452: PARQUET-1265: Segfault on static 
ApplicationVersion initialization
URL: https://github.com/apache/parquet-cpp/pull/452
 
 
   

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/src/parquet/file_reader.cc b/src/parquet/file_reader.cc
index e3280c60..983d2d0b 100644
--- a/src/parquet/file_reader.cc
+++ b/src/parquet/file_reader.cc
@@ -112,7 +112,7 @@ class SerializedRowGroup : public RowGroupReader::Contents {
 
     // PARQUET-816 workaround for old files created by older parquet-mr
     const ApplicationVersion& version = file_metadata_->writer_version();
-    if (version.VersionLt(ApplicationVersion::PARQUET_816_FIXED_VERSION)) {
+    if (version.VersionLt(ApplicationVersion::PARQUET_816_FIXED_VERSION())) {
       // The Parquet MR writer had a bug in 1.2.8 and below where it didn't 
include the
       // dictionary page header size in total_compressed_size and 
total_uncompressed_size
       // (see IMPALA-694). We add padding to compensate.
diff --git a/src/parquet/metadata.cc b/src/parquet/metadata.cc
index 91304cf8..fc420b01 100644
--- a/src/parquet/metadata.cc
+++ b/src/parquet/metadata.cc
@@ -31,12 +31,20 @@
 
 namespace parquet {
 
-const ApplicationVersion ApplicationVersion::PARQUET_251_FIXED_VERSION =
-    ApplicationVersion("parquet-mr version 1.8.0");
-const ApplicationVersion ApplicationVersion::PARQUET_816_FIXED_VERSION =
-    ApplicationVersion("parquet-mr version 1.2.9");
-const ApplicationVersion ApplicationVersion::PARQUET_CPP_FIXED_STATS_VERSION =
-    ApplicationVersion("parquet-cpp version 1.3.0");
+const ApplicationVersion& ApplicationVersion::PARQUET_251_FIXED_VERSION() {
+  static ApplicationVersion version("parquet-mr", 1, 8, 0);
+  return version;
+}
+
+const ApplicationVersion& ApplicationVersion::PARQUET_816_FIXED_VERSION() {
+  static ApplicationVersion version("parquet-mr", 1, 2, 9);
+  return version;
+}
+
+const ApplicationVersion& 
ApplicationVersion::PARQUET_CPP_FIXED_STATS_VERSION() {
+  static ApplicationVersion version("parquet-cpp", 1, 3, 0);
+  return version;
+}
 
 template <typename DType>
 static std::shared_ptr<RowGroupStatistics> MakeTypedColumnStats(
@@ -448,6 +456,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};
@@ -511,7 +523,7 @@ bool ApplicationVersion::VersionEq(const 
ApplicationVersion& other_version) cons
 bool ApplicationVersion::HasCorrectStatistics(Type::type col_type,
                                               SortOrder::type sort_order) 
const {
   // Parquet cpp version 1.3.0 onwards stats are computed correctly for all 
types
-  if ((application_ != "parquet-cpp") || 
(VersionLt(PARQUET_CPP_FIXED_STATS_VERSION))) {
+  if ((application_ != "parquet-cpp") || 
(VersionLt(PARQUET_CPP_FIXED_STATS_VERSION()))) {
     // Only SIGNED are valid
     if (SortOrder::SIGNED != sort_order) {
       return false;
@@ -534,7 +546,7 @@ bool ApplicationVersion::HasCorrectStatistics(Type::type 
col_type,
   }
 
   // PARQUET-251
-  if (VersionLt(PARQUET_251_FIXED_VERSION)) {
+  if (VersionLt(PARQUET_251_FIXED_VERSION())) {
     return false;
   }
 
diff --git a/src/parquet/metadata.h b/src/parquet/metadata.h
index 78503585..3ba57ac0 100644
--- a/src/parquet/metadata.h
+++ b/src/parquet/metadata.h
@@ -38,9 +38,9 @@ using KeyValueMetadata = ::arrow::KeyValueMetadata;
 class ApplicationVersion {
  public:
   // Known Versions with Issues
-  static const ApplicationVersion PARQUET_251_FIXED_VERSION;
-  static const ApplicationVersion PARQUET_816_FIXED_VERSION;
-  static const ApplicationVersion PARQUET_CPP_FIXED_STATS_VERSION;
+  static const ApplicationVersion& PARQUET_251_FIXED_VERSION();
+  static const ApplicationVersion& PARQUET_816_FIXED_VERSION();
+  static const ApplicationVersion& PARQUET_CPP_FIXED_STATS_VERSION();
   // Regular expression for the version format
   // major . minor . patch unknown - prerelease.x + build info
   // Eg: 1.5.0ab-cdh5.5.0+cd
@@ -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;


 

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