Skip to content

Commit dae7efc

Browse files
luffy-zhwgtmac
andcommitted
ORC-1964: [CI] Fix CI ubsan-test with GNU
### What changes were proposed in this pull request? Forcing pthread linking for GCC with sanitizers. ### Why are the changes needed? Fix the CI usbsan-test failure as reported in https://github.com/apache/orc/actions/runs/16258126145/job/45898042155. ### How was this patch tested? Test it locally. ### Was this patch authored or co-authored using generative AI tooling? NO. Closes #2342 from luffy-zh/ORC-1964. Lead-authored-by: luffy-zh <zhnice@outlook.com> Co-authored-by: Hao Zou <34559830+luffy-zh@users.noreply.github.com> Co-authored-by: Gang Wu <ustcwg@gmail.com> Signed-off-by: Gang Wu <ustcwg@gmail.com>
1 parent 8129696 commit dae7efc

3 files changed

Lines changed: 44 additions & 9 deletions

File tree

.github/ubsan-suppressions.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
#
18+
# Add specific undefined behavior suppressions here if needed
19+
# Format:
20+
# symbol:SymbolName
21+
# src:source_file.cc
Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ concurrency:
3030
cancel-in-progress: true
3131

3232
jobs:
33-
asan-test:
34-
name: "ASAN with ${{ matrix.compiler }} on Ubuntu"
33+
sanitizer-test:
34+
name: "Sanitizer with ${{ matrix.compiler }} on Ubuntu"
3535
runs-on: ubuntu-latest
3636
strategy:
3737
fail-fast: false
@@ -58,12 +58,18 @@ jobs:
5858
run: |
5959
mkdir -p build && cd build
6060
cmake .. -DCMAKE_BUILD_TYPE=Debug -DENABLE_ASAN=ON -DENABLE_UBSAN=ON -DBUILD_ENABLE_AVX512=ON -DBUILD_CPP_ENABLE_METRICS=ON -DBUILD_JAVA=OFF
61-
make
61+
cmake --build . --verbose
6262
- name: Run Tests
6363
working-directory: build
6464
env:
65-
ASAN_OPTIONS: detect_leaks=1:symbolize=1:strict_string_checks=1:halt_on_error=0:detect_container_overflow=0
65+
ASAN_OPTIONS: log_path=out.log:detect_leaks=1:symbolize=1:strict_string_checks=1:halt_on_error=1:detect_container_overflow=0
6666
LSAN_OPTIONS: suppressions=${{ github.workspace }}/.github/lsan-suppressions.txt
67-
UBSAN_OPTIONS: print_stacktrace=1
67+
UBSAN_OPTIONS: log_path=out.log:halt_on_error=1:print_stacktrace=1:suppressions=${{ github.workspace }}/.github/ubsan-suppressions.txt
6868
run: |
69-
ctest --output-on-failure
69+
ctest -V --output-on-failure
70+
- name: Save the test output
71+
if: always()
72+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
73+
with:
74+
name: test-output
75+
path: "**/out.log*"

CMakeLists.txt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,15 +181,23 @@ endif()
181181

182182
# Configure Undefined Behavior Sanitizer if enabled
183183
if (ENABLE_UBSAN)
184-
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
185-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined -fno-sanitize=alignment,vptr,function -fno-sanitize-recover=all")
186-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined -fno-sanitize=alignment,vptr,function -fno-sanitize-recover=all")
184+
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
185+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined -fno-sanitize=alignment,vptr -fno-sanitize-recover=all")
186+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined -fno-sanitize=alignment,vptr -fno-sanitize-recover=all")
187187
message(STATUS "Undefined Behavior Sanitizer enabled")
188188
else()
189189
message(WARNING "Undefined Behavior Sanitizer is only supported for GCC and Clang compilers")
190190
endif()
191191
endif()
192192

193+
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
194+
if (ENABLE_ASAN OR ENABLE_UBSAN)
195+
set(CMAKE_THREAD_LIBS_INIT "-lpthread")
196+
set(THREADS_PREFER_PTHREAD_FLAG ON)
197+
message(STATUS "Forcing pthread linking for GCC with sanitizers")
198+
endif()
199+
endif()
200+
193201
enable_testing()
194202

195203
INCLUDE(GNUInstallDirs) # Put it before ThirdpartyToolchain to make CMAKE_INSTALL_LIBDIR available.

0 commit comments

Comments
 (0)