This is an automated email from the ASF dual-hosted git repository.
yangzhg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
The following commit(s) were added to refs/heads/master by this push:
new 794d4e7 fix insert null as string type may coredump (#6615)
794d4e7 is described below
commit 794d4e7aced4cb42b015a78b47ff72f0aea94f26
Author: Zhengguo Yang <[email protected]>
AuthorDate: Mon Sep 13 12:30:34 2021 +0800
fix insert null as string type may coredump (#6615)
---
be/src/olap/field.h | 10 +++++-----
be/src/olap/rowset/segment_v2/binary_plain_page.h | 4 ++--
be/src/olap/rowset/segment_v2/encoding_info.cpp | 1 -
be/src/util/block_compression.cpp | 12 ++++++++----
4 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/be/src/olap/field.h b/be/src/olap/field.h
index ffe0221..7602363 100644
--- a/be/src/olap/field.h
+++ b/be/src/olap/field.h
@@ -180,6 +180,11 @@ public:
// memory allocation.
template <typename DstCellType, typename SrcCellType>
void direct_copy(DstCellType* dst, const SrcCellType& src) const {
+ bool is_null = src.is_null();
+ dst->set_is_null(is_null);
+ if (is_null) {
+ return;
+ }
if (type() == OLAP_FIELD_TYPE_STRING) {
auto dst_slice = reinterpret_cast<Slice*>(dst->mutable_cell_ptr());
auto src_slice = reinterpret_cast<const Slice*>(src.cell_ptr());
@@ -189,11 +194,6 @@ public:
dst_slice->size = src_slice->size;
}
}
- bool is_null = src.is_null();
- dst->set_is_null(is_null);
- if (is_null) {
- return;
- }
return _type_info->direct_copy(dst->mutable_cell_ptr(),
src.cell_ptr());
}
diff --git a/be/src/olap/rowset/segment_v2/binary_plain_page.h
b/be/src/olap/rowset/segment_v2/binary_plain_page.h
index 97e7fa8..0747df2 100644
--- a/be/src/olap/rowset/segment_v2/binary_plain_page.h
+++ b/be/src/olap/rowset/segment_v2/binary_plain_page.h
@@ -215,7 +215,7 @@ public:
char* destination =
(char*)dst->column_block()->pool()->allocate(mem_size);
if (destination == nullptr) {
return Status::MemoryAllocFailed(
- strings::Substitute("memory allocate failed, size:$0",
mem_size));
+ strings::Substitute("memory allocate failed, size:$0",
mem_size));
}
for (int i = 0; i < max_fetch; ++i) {
out->relocate(destination);
@@ -245,7 +245,7 @@ public:
private:
// Return the offset within '_data' where the string value with index
'idx' can be found.
- uint32_t offset(int idx) const {
+ uint32_t offset(size_t idx) const {
if (idx >= _num_elems) {
return _offsets_pos;
}
diff --git a/be/src/olap/rowset/segment_v2/encoding_info.cpp
b/be/src/olap/rowset/segment_v2/encoding_info.cpp
index e4ce43c..801cdb4 100644
--- a/be/src/olap/rowset/segment_v2/encoding_info.cpp
+++ b/be/src/olap/rowset/segment_v2/encoding_info.cpp
@@ -255,7 +255,6 @@ EncodingInfoResolver::EncodingInfoResolver() {
_add_map<OLAP_FIELD_TYPE_VARCHAR, PLAIN_ENCODING>();
_add_map<OLAP_FIELD_TYPE_VARCHAR, PREFIX_ENCODING, true>();
- _add_map<OLAP_FIELD_TYPE_STRING, DICT_ENCODING>();
_add_map<OLAP_FIELD_TYPE_STRING, PLAIN_ENCODING>();
_add_map<OLAP_FIELD_TYPE_STRING, PREFIX_ENCODING, true>();
diff --git a/be/src/util/block_compression.cpp
b/be/src/util/block_compression.cpp
index 290ffec..8ba1e4f 100644
--- a/be/src/util/block_compression.cpp
+++ b/be/src/util/block_compression.cpp
@@ -23,11 +23,11 @@
#include <snappy/snappy.h>
#include <zlib.h>
+#include <limits>
+
#include "gutil/strings/substitute.h"
#include "util/faststring.h"
-#include <limits>
-
namespace doris {
using strings::Substitute;
@@ -52,6 +52,10 @@ public:
~Lz4BlockCompression() override {}
Status compress(const Slice& input, Slice* output) const override {
+ if (input.size > std::numeric_limits<int32_t>::max() ||
+ output->size > std::numeric_limits<int32_t>::max()) {
+ return Status::InvalidArgument("LZ4 cannot handle data large than
2G");
+ }
auto compressed_len =
LZ4_compress_default(input.data, output->data, input.size,
output->size);
if (compressed_len == 0) {
@@ -73,11 +77,11 @@ public:
return Status::OK();
}
- size_t max_compressed_len(size_t len) const override {
+ size_t max_compressed_len(size_t len) const override {
if (len > std::numeric_limits<int32_t>::max()) {
return 0;
}
- return LZ4_compressBound(len);
+ return LZ4_compressBound(len);
}
};
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]