Skip to content

Commit fe92778

Browse files
committed
ARROW-14515: [R] Add clang sanitizer to crossbow
We should upstream r-fedora-clang-devel-san.dockerfile to rhub and use theirs when we do Closes #11577 from jonkeane/ARROW-14515-clang-san Authored-by: Jonathan Keane <jkeane@gmail.com> Signed-off-by: Jonathan Keane <jkeane@gmail.com>
1 parent e907a9f commit fe92778

File tree

4 files changed

+130
-3
lines changed

4 files changed

+130
-3
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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+
# Fedora-clang-devel with the sanitizer enabled, this should/will
19+
# be upstreamed to rhub, so separated out like this
20+
21+
# start with the Docker 'base R' Debian-based image
22+
FROM rhub/fedora-clang:latest
23+
24+
# TODO: rhub maintainer when we upstream
25+
26+
ENV CRAN http://cran.r-project.org
27+
28+
RUN cd /tmp \
29+
&& svn co https://svn.r-project.org/R/trunk R-devel
30+
31+
ENV RPREFIX /opt/R-devel
32+
33+
ENV ROPTIONS --with-x --with-recommended-packages --enable-R-shlib --enable-R-static-lib
34+
35+
ENV CC /usr/bin/clang
36+
ENV CXX /usr/bin/clang++
37+
ENV F77 gfortran
38+
ENV CPP cpp
39+
40+
RUN yum -y install rsync
41+
RUN dnf install -y libcxx-devel
42+
43+
RUN cd /tmp/R-devel \
44+
&& ./tools/rsync-recommended \
45+
&& R_PAPERSIZE=letter \
46+
R_BATCHSAVE="--no-save --no-restore" \
47+
CC="clang -fsanitize=address,undefined -fno-sanitize=float-divide-by-zero -fno-omit-frame-pointer" \
48+
CXX="clang++ -stdlib=libc++ -fsanitize=address,undefined -fno-sanitize=float-divide-by-zero -fno-omit-frame-pointer" \
49+
CFLAGS="-g -O3 -Wall -pedantic -mtune=native" \
50+
FFLAGS="-g -O2 -mtune=native" \
51+
FCFLAGS="-g -O2 -mtune=native" \
52+
CXXFLAGS="-g -O3 -Wall -pedantic -mtune=native" \
53+
MAIN_LD="clang++ -stdlib=libc++ -fsanitize=undefined,address" \
54+
R_OPENMP_CFLAGS=-fopenmp \
55+
./configure --prefix=${RPREFIX} ${ROPTIONS} \
56+
&& make \
57+
&& make install
58+
59+
# TODO: re-enable when upstreamed?
60+
# COPY xvfb-run /usr/local/bin/xvfb-run
61+
62+
# RUN chmod +x /usr/local/bin/xvfb-run && \
63+
# rm -f /bin/xvfb-run /usr/bin/xvfb-run
64+
65+
ENV RHUB_PLATFORM linux-x86_64-fedora-clang
66+
67+
# More verbose UBSAN/SAN output (cf #3) -- this is still somewhat speculative
68+
# Entry copied from Prof Ripley's setup described at http://www.stats.ox.ac.uk/pub/bdr/memtests/README.txt
69+
ENV ASAN_OPTIONS 'alloc_dealloc_mismatch=0:detect_leaks=0:detect_odr_violation=0'
70+
71+
ENV PATH=${RPREFIX}/bin:$PATH
72+
73+
RUN cd $RPREFIX/bin \
74+
&& mv R Rdevel \
75+
&& cp Rscript Rscriptdevel \
76+
&& ln -s Rdevel RDsan \
77+
&& ln -s Rscriptdevel RDscriptsan

ci/scripts/r_sanitize.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,21 @@ unset ARROW_R_DEV
3434

3535
export UBSAN_OPTIONS="print_stacktrace=1,suppressions=/arrow/r/tools/ubsan.supp"
3636

37+
# run tests
3738
pushd tests
3839
${R_BIN} < testthat.R > testthat.out 2>&1 || { cat testthat.out; exit 1; }
39-
popd
40-
${R_BIN} -e 'library(arrow); testthat::test_examples(".")' >> testthat.out 2>&1 || { cat testthat.out; exit 1; }
4140

4241
cat testthat.out
4342
if grep -q "runtime error" testthat.out; then
4443
exit 1
4544
fi
45+
46+
# run examples
47+
popd
48+
${R_BIN} -e 'library(arrow); testthat::test_examples(".")' >> examples.out 2>&1 || { cat examples.out; exit 1; }
49+
50+
cat examples.out
51+
if grep -q "runtime error" examples.out; then
52+
exit 1
53+
fi
4654
popd

dev/tasks/tasks.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,6 +1161,12 @@ tasks:
11611161
UBUNTU: 18.04
11621162
run: ubuntu-r-sanitizer
11631163

1164+
test-fedora-r-clang-sanitizer:
1165+
ci: azure
1166+
template: docker-tests/azure.linux.yml
1167+
params:
1168+
run: fedora-r-clang-sanitizer
1169+
11641170
revdep-r-check:
11651171
ci: github
11661172
template: r/github.linux.revdepcheck.yml

docker-compose.yml

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ x-hierarchy:
136136
- ubuntu-cpp-sanitizer
137137
- ubuntu-cpp-thread-sanitizer
138138
- ubuntu-r-sanitizer
139+
- r-fedora-clang-devel-san:
140+
- fedora-r-clang-sanitizer
139141
- ubuntu-r-valgrind
140142
- python-sdist
141143
- r
@@ -271,7 +273,7 @@ services:
271273
ARROW_USE_LD_GOLD: "ON"
272274
BUILD_WARNING_LEVEL: "PRODUCTION"
273275
volumes: *conda-volumes
274-
command:
276+
command:
275277
["/arrow/ci/scripts/cpp_build.sh /arrow /build &&
276278
/arrow/ci/scripts/cpp_test.sh /arrow /build"]
277279

@@ -1154,6 +1156,40 @@ services:
11541156
/bin/bash -c "
11551157
/arrow/ci/scripts/r_sanitize.sh /arrow"
11561158
1159+
fedora-r-clang-sanitizer:
1160+
image: ${REPO}:r-rhub-fedora-clang-devel-latest
1161+
build:
1162+
context: .
1163+
dockerfile: ci/docker/linux-r.dockerfile
1164+
cache_from:
1165+
- ${REPO}:r-rhub-fedora-clang-devel-latest
1166+
args:
1167+
base: ${REPO}:r-fedora-clang-devel-san
1168+
r_dev: ${ARROW_R_DEV}
1169+
devtoolset_version: ${DEVTOOLSET_VERSION}
1170+
r_bin: RDsan
1171+
tz: ${TZ}
1172+
shm_size: *shm-size
1173+
environment:
1174+
LIBARROW_DOWNLOAD: "false"
1175+
ARROW_SOURCE_HOME: "/arrow"
1176+
ARROW_R_DEV: ${ARROW_R_DEV}
1177+
# To test for CRAN release, delete ^^ these two env vars so we download the Apache release
1178+
ARROW_USE_PKG_CONFIG: "false"
1179+
volumes:
1180+
- .:/arrow:delegated
1181+
command: >
1182+
/bin/bash -c "
1183+
/arrow/ci/scripts/r_sanitize.sh /arrow"
1184+
1185+
r-fedora-clang-devel-san:
1186+
image: ${REPO}:r-fedora-clang-devel-san
1187+
build:
1188+
context: .
1189+
dockerfile: ci/docker/r-fedora-clang-devel-san.dockerfile
1190+
cache_from:
1191+
- ${REPO}:r-fedora-clang-devel-san
1192+
11571193
ubuntu-r-valgrind:
11581194
# Only 18.04 and amd64 supported
11591195
# Usage:

0 commit comments

Comments
 (0)