Skip to content

Commit 96933ae

Browse files
authored
Merge branch 'main' into codex/fix-paimon-package-config
2 parents b24557f + 02621ef commit 96933ae

21 files changed

Lines changed: 226 additions & 157 deletions

build_support/lsan-suppressions.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,10 @@
1717

1818
# False positive from atexit() registration in libc
1919
leak:*__new_exitfn*
20+
21+
# Lance's Rust/Tokio runtime can leave worker/TLS allocations alive at process
22+
# exit. Suppress these third-party runtime shutdown leftovers without hiding
23+
# all leaks from liblance_lib_rc.so.
24+
leak:tokio::runtime::blocking::pool::spawn_blocking
25+
leak:tokio::runtime::scheduler::multi_thread::worker::create
26+
leak:std::thread::Builder::spawn_unchecked

build_support/ubsan-suppressions.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17+
18+
# Arrow's ISO8601 string-to-timestamp parser intentionally reaches the int64
19+
# nanosecond boundary for values such as 1677-09-21 00:12:43.145224192.
20+
signed-integer-overflow:std::chrono::__duration_cast_impl

cmake_modules/BuildUtils.cmake

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ function(add_paimon_lib LIB_NAME)
8989
# Generate a single "objlib" from all C++ modules and link
9090
# that "objlib" into each library kind, to avoid compiling twice
9191
add_library(${LIB_NAME}_objlib OBJECT ${ARG_SOURCES})
92+
target_link_libraries(${LIB_NAME}_objlib
93+
PRIVATE "$<BUILD_INTERFACE:paimon_sanitizer_flags>")
9294
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
9395
target_compile_options(${LIB_NAME}_objlib PRIVATE -Wno-global-constructors)
9496
endif()
@@ -177,12 +179,12 @@ function(add_paimon_lib LIB_NAME)
177179
PUBLIC "$<BUILD_INTERFACE:paimon_sanitizer_flags>")
178180

179181
if(NOT APPLE)
180-
target_link_options(${LIB_NAME}_shared
181-
PRIVATE
182-
-Wl,--exclude-libs,ALL
183-
-Wl,-Bsymbolic
184-
-Wl,-z,defs
185-
-Wl,--gc-sections)
182+
set(SHARED_LINK_OPTIONS -Wl,--exclude-libs,ALL -Wl,-Bsymbolic
183+
-Wl,--gc-sections)
184+
if(NOT PAIMON_USE_ASAN AND NOT PAIMON_USE_UBSAN)
185+
list(APPEND SHARED_LINK_OPTIONS -Wl,-z,defs)
186+
endif()
187+
target_link_options(${LIB_NAME}_shared PRIVATE ${SHARED_LINK_OPTIONS})
186188
endif()
187189

188190
install(TARGETS ${LIB_NAME}_shared ${INSTALL_IS_OPTIONAL}

cmake_modules/san-config.cmake

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ endif()
2525

2626
if(PAIMON_USE_UBSAN)
2727
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
28-
target_compile_options(paimon_sanitizer_flags INTERFACE -fsanitize=undefined
29-
-fno-omit-frame-pointer)
28+
target_compile_options(paimon_sanitizer_flags
29+
INTERFACE -fsanitize=undefined -fno-sanitize=vptr
30+
-fno-omit-frame-pointer)
3031
target_link_options(paimon_sanitizer_flags INTERFACE -fsanitize=undefined)
3132
message(STATUS "Undefined Behavior Sanitizer enabled")
3233
else()

src/paimon/common/data/columnar/columnar_utils.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ class ColumnarUtils {
108108
MemoryPool* pool) {
109109
auto view = GetView(array, pos);
110110
std::shared_ptr<Bytes> bytes = Bytes::AllocateBytes(view.size(), pool);
111-
memcpy(bytes->data(), view.data(), view.size());
111+
if (!view.empty()) {
112+
memcpy(bytes->data(), view.data(), view.size());
113+
}
112114
return bytes;
113115
}
114116
};

src/paimon/common/data/decimal.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,14 @@ Decimal Decimal::FromUnscaledBytes(int32_t precision, int32_t scale, Bytes* byte
107107

108108
int32_t Decimal::clz_u128(uint128_t u) {
109109
uint64_t hi = u >> 64;
110+
if (hi != 0) {
111+
return __builtin_clzll(hi);
112+
}
110113
uint64_t lo = u;
111-
int32_t retval[3] = {__builtin_clzll(hi), __builtin_clzll(lo) + 64, 128};
112-
int32_t idx = !hi + ((!lo) & (!hi));
113-
return retval[idx];
114+
if (lo != 0) {
115+
return __builtin_clzll(lo) + 64;
116+
}
117+
return 128;
114118
}
115119

116120
int32_t Decimal::count_leading_zero_bytes(uint128_t u) {

src/paimon/common/data/decimal_test.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,12 @@ TEST(DecimalTest, TestCompatibleWithJava) {
130130
}
131131

132132
TEST(DecimalTest, TestCompareTo) {
133-
auto CheckResult = [](const Decimal& decimal1, const Decimal& decimal2) {
133+
auto min_int128 = DecimalUtils::StrToInt128("-170141183460469231731687303715884105728").value();
134+
auto can_negate = [min_int128](const Decimal& decimal) {
135+
return decimal.Value() != min_int128;
136+
};
137+
138+
auto CheckResult = [can_negate](const Decimal& decimal1, const Decimal& decimal2) {
134139
ASSERT_FALSE(decimal1 < decimal1);
135140
ASSERT_FALSE(decimal1 > decimal1);
136141
ASSERT_EQ(decimal1, decimal1);
@@ -143,6 +148,9 @@ TEST(DecimalTest, TestCompareTo) {
143148
ASSERT_EQ(decimal3.CompareTo(decimal1), 0);
144149
ASSERT_EQ(decimal3, decimal1);
145150

151+
if (!can_negate(decimal1) || !can_negate(decimal2)) {
152+
return;
153+
}
146154
Decimal negative_decimal1(decimal1.Precision(), decimal1.Scale(), -decimal1.Value());
147155
Decimal negative_decimal2(decimal2.Precision(), decimal2.Scale(), -decimal2.Value());
148156
ASSERT_EQ(negative_decimal1.CompareTo(negative_decimal2), 1);
@@ -154,10 +162,13 @@ TEST(DecimalTest, TestCompareTo) {
154162
ASSERT_EQ(negative_decimal3, negative_decimal1);
155163
};
156164

157-
auto CheckEqual = [](const Decimal& decimal1, const Decimal& decimal2) {
165+
auto CheckEqual = [can_negate](const Decimal& decimal1, const Decimal& decimal2) {
158166
ASSERT_EQ(decimal1.CompareTo(decimal2), 0);
159167
ASSERT_EQ(decimal2.CompareTo(decimal1), 0);
160168

169+
if (!can_negate(decimal1) || !can_negate(decimal2)) {
170+
return;
171+
}
161172
Decimal negative_decimal1(decimal1.Precision(), decimal1.Scale(), -decimal1.Value());
162173
Decimal negative_decimal2(decimal2.Precision(), decimal2.Scale(), -decimal2.Value());
163174
ASSERT_EQ(negative_decimal1.CompareTo(negative_decimal2), 0);

src/paimon/common/global_index/global_index_utils_test.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ class GlobalIndexUtilsTest : public ::testing::Test {
3131
/// Helper to create a valid ArrowArray with the given number of int32 elements.
3232
static ArrowArray CreateInt32Array(const std::vector<int32_t>& values) {
3333
arrow::Int32Builder builder;
34-
EXPECT_TRUE(builder.AppendValues(values).ok());
34+
if (!values.empty()) {
35+
EXPECT_TRUE(builder.AppendValues(values).ok());
36+
}
3537
std::shared_ptr<arrow::Array> array;
3638
EXPECT_TRUE(builder.Finish(&array).ok());
3739
ArrowArray c_array;

src/paimon/common/io/memory_segment_output_stream.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ void MemorySegmentOutputStream::WriteString(const std::string& str) {
5252

5353
void MemorySegmentOutputStream::Write(const char* data, uint32_t size) {
5454
auto bytes = std::make_shared<Bytes>(size, pool_.get());
55-
memcpy(bytes->data(), data, size);
55+
if (size != 0) {
56+
memcpy(bytes->data(), data, size);
57+
}
5658
auto segment = MemorySegment::Wrap(bytes);
5759
Write(segment, 0, segment.Size());
5860
}

src/paimon/common/memory/memory_segment.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,18 @@ class PAIMON_EXPORT MemorySegment {
109109
inline void Get(int32_t index, T* dst, int32_t offset, int32_t length) const {
110110
assert(static_cast<int32_t>(dst->size()) >= (offset + length));
111111
assert(size_ >= (index + length));
112-
std::memcpy(const_cast<char*>(dst->data()) + offset, data_ + index, length);
112+
if (length != 0) {
113+
std::memcpy(const_cast<char*>(dst->data()) + offset, data_ + index, length);
114+
}
113115
}
114116

115117
template <typename T>
116118
inline void Put(int32_t index, const T& src, int32_t offset, int32_t length) {
117119
assert(static_cast<int32_t>(src.size()) >= (offset + length));
118120
assert(size_ >= (index + length));
119-
std::memcpy(MutableData() + index, src.data() + offset, length);
121+
if (length != 0) {
122+
std::memcpy(MutableData() + index, src.data() + offset, length);
123+
}
120124
}
121125

122126
template <typename T>
@@ -147,13 +151,16 @@ class PAIMON_EXPORT MemorySegment {
147151
assert(offset >= 0);
148152
assert(target_offset >= 0);
149153
assert(num_bytes >= 0);
150-
151-
std::memcpy(target->MutableData() + target_offset, data_ + offset, num_bytes);
154+
if (num_bytes != 0) {
155+
std::memcpy(target->MutableData() + target_offset, data_ + offset, num_bytes);
156+
}
152157
}
153158

154159
void CopyToUnsafe(int32_t offset, void* target, int32_t target_offset,
155160
int32_t num_bytes) const {
156-
std::memcpy(static_cast<char*>(target) + target_offset, data_ + offset, num_bytes);
161+
if (num_bytes != 0) {
162+
std::memcpy(static_cast<char*>(target) + target_offset, data_ + offset, num_bytes);
163+
}
157164
}
158165

159166
int32_t Compare(const MemorySegment& seg2, int32_t offset1, int32_t offset2, int32_t len) const;

0 commit comments

Comments
 (0)