Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions thirdparty/download-thirdparty.sh
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,13 @@ if [[ " ${TP_ARCHIVES[*]} " =~ " ARROW " ]]; then
# apache-arrow-17.0.0-force-write-int96-timestamps.patch :
# Introducing the parameter that forces writing int96 timestampes for compatibility with Paimon cpp.
patch -p1 <"${TP_PATCH_DIR}/apache-arrow-17.0.0-force-write-int96-timestamps.patch"

# apache-arrow-17.0.0-status-inline-static-fix.patch :
# Move Status::message()/detail() empty sentinels out of header
# inline function-local statics. Clang can place those weak inline
# std::string objects in RELRO, then crash while initializing them.
patch -p1 <"${TP_PATCH_DIR}/apache-arrow-17.0.0-status-inline-static-fix.patch"

touch "${PATCHED_MARK}"
fi
cd -
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
diff --git a/cpp/src/arrow/status.cc b/cpp/src/arrow/status.cc
index a9581cadc9..1b7ee7df62 100644
--- a/cpp/src/arrow/status.cc
+++ b/cpp/src/arrow/status.cc
@@ -17,6 +17,17 @@

namespace arrow {

+const std::string& Status::NoMessage() {
+ static const std::string* no_message = new std::string();
+ return *no_message;
+}
+
+const std::shared_ptr<StatusDetail>& Status::NoDetail() {
+ static const std::shared_ptr<StatusDetail>* no_detail =
+ new std::shared_ptr<StatusDetail>();
+ return *no_detail;
+}
+
Status::Status(StatusCode code, const std::string& msg)
: Status::Status(code, msg, nullptr) {}

diff --git a/cpp/src/arrow/status.h b/cpp/src/arrow/status.h
index 983b61629d..a49a982922 100644
--- a/cpp/src/arrow/status.h
+++ b/cpp/src/arrow/status.h
@@ -330,14 +330,18 @@ class ARROW_EXPORT [[nodiscard]] Status : public util::EqualityComparable<Status

/// \brief Return the specific error message attached to this status.
const std::string& message() const {
- static const std::string no_message = "";
- return ok() ? no_message : state_->msg;
+ if (ARROW_PREDICT_FALSE(state_ != NULLPTR)) {
+ return state_->msg;
+ }
+ return NoMessage();
}

/// \brief Return the status detail attached to this message.
const std::shared_ptr<StatusDetail>& detail() const {
- static std::shared_ptr<StatusDetail> no_detail = NULLPTR;
- return state_ ? state_->detail : no_detail;
+ if (ARROW_PREDICT_FALSE(state_ != NULLPTR)) {
+ return state_->detail;
+ }
+ return NoDetail();
}

const void* debug_state_addr() const { return state_; }
@@ -396,6 +400,8 @@ class ARROW_EXPORT [[nodiscard]] Status : public util::EqualityComparable<Status
delete state_;
state_ = NULLPTR;
}
+ static const std::string& NoMessage();
+ static const std::shared_ptr<StatusDetail>& NoDetail();
void CopyFrom(const Status& s);
inline void MoveFrom(Status& s);
};
Loading