From 6f9182fff7520800016e862fe458c5b1be691b26 Mon Sep 17 00:00:00 2001 From: Hu Shenggang Date: Mon, 25 May 2026 12:03:11 +0800 Subject: [PATCH 1/2] [fix](be) Avoid unsigned underflow in JSON modify path ### What problem does this PR solve? Issue Number: None Problem Summary: JSON modify functions build a parent path by iterating to the element before the last JSON path leg. The loop used `get_leg_vector_size() - 1` on an unsigned size, which can underflow for an empty path expression even though normal root-path execution resolves to the root value before that branch. Cache the leg count once, assert the non-empty invariant for the insert-parent branch, and use `j + 1 < legs_count` to avoid unsigned subtraction while preserving behavior. ### Release note None ### Check List (For Author) - Test: - Manual test: `git diff --check` - Manual test: `DORIS_HOME=/mnt/disk7/hushenggang/doris-fix-spill ninja -C be/ut_build_ASAN -j 1 src/exprs/CMakeFiles/Exprs.dir/function/function_jsonb.cpp.o` - Behavior changed: No - Does this need documentation: No --- be/src/exprs/function/function_jsonb.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/be/src/exprs/function/function_jsonb.cpp b/be/src/exprs/function/function_jsonb.cpp index 1f11e496877200..17e087cffac471 100644 --- a/be/src/exprs/function/function_jsonb.cpp +++ b/be/src/exprs/function/function_jsonb.cpp @@ -2048,6 +2048,7 @@ class FunctionJsonbModify : public IFunction { bool replace = false; parents.emplace_back(json_documents[row_idx]->getValue()); + const auto legs_count = json_path[path_index].get_leg_vector_size(); if (find_result.value) { // find target path, replace it with the new value. replace = true; @@ -2059,7 +2060,8 @@ class FunctionJsonbModify : public IFunction { } else { // does not find target path, insert the new value. JsonbPath new_path; - for (size_t j = 0; j < json_path[path_index].get_leg_vector_size() - 1; ++j) { + DCHECK_GT(legs_count, 0); + for (size_t j = 0; j + 1 < legs_count; ++j) { auto* current_leg = json_path[path_index].get_leg_from_leg_vector(j); std::unique_ptr leg = std::make_unique( current_leg->leg_ptr, current_leg->leg_len, @@ -2073,7 +2075,6 @@ class FunctionJsonbModify : public IFunction { } } - const auto legs_count = json_path[path_index].get_leg_vector_size(); leg_info* last_leg = legs_count > 0 ? json_path[path_index].get_leg_from_leg_vector(legs_count - 1) From de24ddcd1f296d6d760be7965723fef26c97e009 Mon Sep 17 00:00:00 2001 From: Hu Shenggang Date: Mon, 25 May 2026 15:50:11 +0800 Subject: [PATCH 2/2] [fix](build) Fix macOS BE UT runner setup ### What problem does this PR solve? Issue Number: None Problem Summary: The macOS BE UT workflow relies on `JAVA_HOME_17_X64` before running `run-be-ut.sh`. On the current macOS runner the job resolves Java 25 instead, and the BE UT script rejects it because the build requires JDK 17. After switching Java, the job also needs the Homebrew LLVM toolchain to make OpenMP detection succeed, and arm64 runners must download the matching darwin-arm64 third-party archive instead of the x86_64 archive. Set up Temurin JDK 17 explicitly, point Doris to Homebrew LLVM, and select the Darwin third-party archive by runner architecture. ### Release note None ### Check List (For Author) - Test: - Manual test: `git diff --check` - Manual test: `DORIS_HOME=/mnt/disk7/hushenggang/doris-fix-spill ninja -C be/ut_build_ASAN -j 1 src/exprs/CMakeFiles/Exprs.dir/function/function_jsonb.cpp.o` - Behavior changed: No - Does this need documentation: No --- .github/workflows/be-ut-mac.yml | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/.github/workflows/be-ut-mac.yml b/.github/workflows/be-ut-mac.yml index 030d6463e56443..9202105825b0e6 100644 --- a/.github/workflows/be-ut-mac.yml +++ b/.github/workflows/be-ut-mac.yml @@ -56,6 +56,13 @@ jobs: max-size: "5G" restore-keys: BE-UT-macOS- + - name: Set up JDK 17 + if: ${{ github.event_name == 'schedule' || steps.filter.outputs.be_changes == 'true' }} + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '17' + - name: Run UT ${{ github.ref }} if: ${{ github.event_name == 'schedule' || steps.filter.outputs.be_changes == 'true' }} run: | @@ -86,15 +93,29 @@ jobs: pushd thirdparty branch="${{ github.base_ref }}" + arch="$(uname -m)" + if [[ "${arch}" == "amd64" ]]; then + arch="x86_64" + fi + thirdparty_archive="doris-thirdparty-prebuilt-darwin-${arch}.tar.xz" if [[ -z "${branch}" ]] || [[ "${branch}" == 'master' ]]; then - curl -L https://github.com/apache/doris-thirdparty/releases/download/automation/doris-thirdparty-prebuilt-darwin-x86_64.tar.xz \ - -o doris-thirdparty-prebuilt-darwin-x86_64.tar.xz + curl -L "https://github.com/apache/doris-thirdparty/releases/download/automation/${thirdparty_archive}" \ + -o "${thirdparty_archive}" else - curl -L "https://github.com/apache/doris-thirdparty/releases/download/automation-${branch/branch-/}/doris-thirdparty-prebuilt-darwin-x86_64.tar.xz" \ - -o doris-thirdparty-prebuilt-darwin-x86_64.tar.xz + curl -L "https://github.com/apache/doris-thirdparty/releases/download/automation-${branch/branch-/}/${thirdparty_archive}" \ + -o "${thirdparty_archive}" fi - tar -xvf doris-thirdparty-prebuilt-darwin-x86_64.tar.xz + tar -xvf "${thirdparty_archive}" popd - export JAVA_HOME="${JAVA_HOME_17_X64%\/}" + llvm_prefix="$(brew --prefix llvm@16)" + export DORIS_TOOLCHAIN=clang + export DORIS_CLANG_HOME="${llvm_prefix}" + export CC="${llvm_prefix}/bin/clang" + export CXX="${llvm_prefix}/bin/clang++" + export PATH="${llvm_prefix}/bin:${PATH}" + export LDFLAGS="-L${llvm_prefix}/lib ${LDFLAGS:-}" + export CPPFLAGS="-I${llvm_prefix}/include ${CPPFLAGS:-}" + export CMAKE_PREFIX_PATH="${llvm_prefix}:${CMAKE_PREFIX_PATH:-}" + export JAVA_HOME="${JAVA_HOME%\/}" ./run-be-ut.sh --run -j "$(nproc)" --clean