Skip to content

Commit 12424cd

Browse files
authored
GH-46394: [C++][R] gcc-UBSAN errors on CRAN (#46397)
### Rationale for this change Fix gcc-UBSAN CI job to be correctly running, then fix the UBSAN error. ### What changes are included in this PR? * Generalize our sanitizer jobs and use rhub's containers for this. wch/r-debug looks like it's out of date (hence why we didn't catch this), and it's easier to use a matrix of images with rhubarb anyway. * Initialize the `_quoted` variable — we could also cast it to boolean where the UBSAN popped, but this seems to be enough. ### Are these changes tested? Yes ### Are there any user-facing changes? No * GitHub Issue: #46394 Authored-by: Jonathan Keane <jkeane@gmail.com> Signed-off-by: Jacob Wujciak-Jens <jacob@wujciak.de>
1 parent 6ab37dd commit 12424cd

4 files changed

Lines changed: 73 additions & 85 deletions

File tree

cpp/src/arrow/csv/parser.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,11 @@ class ValueDescWriter {
144144

145145
protected:
146146
ValueDescWriter(MemoryPool* pool, int64_t values_capacity)
147-
: values_size_(0), values_capacity_(values_capacity), status_(Status::OK()) {
147+
: values_size_(0),
148+
values_capacity_(values_capacity),
149+
quoted_(false),
150+
saved_values_size_(0),
151+
status_(Status::OK()) {
148152
status_ &= AllocateResizableBuffer(values_capacity_ * sizeof(*values_), pool)
149153
.Value(&values_buffer_);
150154
if (status_.ok()) {
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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+
{% import 'macros.jinja' as macros with context %}
19+
20+
{{ macros.github_header() }}
21+
22+
jobs:
23+
r-linux-sanitizers:
24+
name: "rhub/{{ '${{ matrix.config.r_image }}' }}"
25+
runs-on: ubuntu-latest
26+
timeout-minutes: {{ timeout|default(60) }}
27+
env:
28+
R_PRUNE_DEPS: TRUE
29+
R_ORG: "rhub"
30+
R_IMAGE: "{{ '${{ matrix.config.r_image }}' }}"
31+
R_TAG: "latest"
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
config:
36+
# See https://r-hub.github.io/containers/
37+
- { r_image: "clang-asan", skip_vignettes: true }
38+
- { r_image: "clang-ubsan", skip_vignettes: true }
39+
- { r_image: "gcc-asan", skip_vignettes: true} # includes both asan and ubsan
40+
steps:
41+
{{ macros.github_checkout_arrow()|indent }}
42+
{{ macros.github_install_archery()|indent }}
43+
44+
- name: Docker Run
45+
shell: bash
46+
env:
47+
{{ macros.github_set_sccache_envvars()|indent(8)}}
48+
run: archery docker run -e SKIP_VIGNETTES={{ '${{ matrix.config.skip_vignettes }}' }} r-san
49+
- name: Dump install logs
50+
run: cat arrow/r/arrow.Rcheck/00install.out
51+
if: always()
52+
- name: Dump test logs
53+
run: cat arrow/r/arrow.Rcheck/tests/testthat.Rout*
54+
if: always()
55+
- name: Save the test output
56+
if: always()
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: test-output-{{ "${{ matrix.config.r_image }}" }}
60+
path: arrow/r/arrow.Rcheck/tests/testthat.Rout*

dev/tasks/tasks.yml

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,30 +1081,11 @@ tasks:
10811081
r_tag: latest
10821082
flags: "-e LIBARROW_MINIMAL=TRUE"
10831083

1084-
test-r-linux-sanitizer:
1084+
test-r-linux-sanitizers:
10851085
ci: github
1086-
template: docker-tests/github.linux.yml
1087-
params:
1088-
env:
1089-
R_PRUNE_DEPS: TRUE
1090-
image: ubuntu-r-sanitizer
1091-
timeout: 120
1092-
1093-
test-r-clang-asan:
1094-
ci: github
1095-
template: docker-tests/github.linux.yml
1086+
template: r/github.linux.sanitizers.yml
10961087
params:
1097-
env:
1098-
R_PRUNE_DEPS: TRUE
1099-
image: r-clang-asan
1100-
1101-
test-r-clang-ubsan:
1102-
ci: github
1103-
template: docker-tests/github.linux.yml
1104-
params:
1105-
env:
1106-
R_PRUNE_DEPS: TRUE
1107-
image: r-clang-ubsan
1088+
timeout: 240 # 4 hours
11081089

11091090
test-r-m1-san:
11101091
ci: github

docker-compose.yml

Lines changed: 5 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,12 @@ x-hierarchy:
158158
- ubuntu-cpp-sanitizer
159159
- ubuntu-cpp-thread-sanitizer
160160
- ubuntu-cpp-emscripten
161-
- ubuntu-r-sanitizer
162161
- ubuntu-r-valgrind
163162
- ubuntu-swift
164163
- ubuntu-verify-rc
165-
- r-clang-asan
166-
- r-clang-ubsan
167164
- r
168165
- r-revdepcheck
166+
- r-san
169167
# helper services
170168
- impala
171169
- postgres
@@ -1690,70 +1688,15 @@ services:
16901688
command: >
16911689
/bin/bash -c "/arrow/ci/scripts/r_test.sh /arrow"
16921690
1693-
ubuntu-r-sanitizer:
1694-
# Only amd64 supported
1695-
# Usage:
1696-
# docker compose build ubuntu-r-sanitizer
1697-
# docker compose run ubuntu-r-sanitizer
1698-
image: ${REPO}:amd64-ubuntu-r-sanitizer
1699-
cap_add:
1700-
# LeakSanitizer and gdb requires ptrace(2)
1701-
- SYS_PTRACE
1691+
r-san:
1692+
image: ${REPO}:r-${R_ORG}-${R_IMAGE}
17021693
build:
17031694
context: .
17041695
dockerfile: ci/docker/linux-r.dockerfile
17051696
cache_from:
1706-
- ${REPO}:amd64-ubuntu-r-sanitizer
1697+
- ${REPO}:r-${R_ORG}-${R_IMAGE}
17071698
args:
1708-
base: wch1/r-debug:latest
1709-
cmake: ${CMAKE}
1710-
r_bin: RDsan
1711-
tz: ${TZ}
1712-
r_prune_deps: ${R_PRUNE_DEPS}
1713-
environment:
1714-
<<: [*common, *ccache]
1715-
ARROW_SOURCE_HOME: "/arrow"
1716-
volumes: *ubuntu-volumes
1717-
command: >
1718-
/bin/bash -c "
1719-
/arrow/ci/scripts/r_sanitize.sh /arrow"
1720-
1721-
r-clang-asan:
1722-
image: ${REPO}:r-rhub-clang-devel-latest
1723-
build:
1724-
context: .
1725-
dockerfile: ci/docker/linux-r.dockerfile
1726-
cache_from:
1727-
- ${REPO}:r-rhub-clang-devel-latest
1728-
args:
1729-
base: rhub/clang-asan
1730-
cmake: ${CMAKE}
1731-
r_dev: ${ARROW_R_DEV}
1732-
r_bin: R
1733-
tz: ${TZ}
1734-
r_prune_deps: ${R_PRUNE_DEPS}
1735-
shm_size: *shm-size
1736-
environment:
1737-
<<: *common
1738-
LIBARROW_DOWNLOAD: "false"
1739-
ARROW_SOURCE_HOME: "/arrow"
1740-
ARROW_R_DEV: ${ARROW_R_DEV}
1741-
ARROW_USE_PKG_CONFIG: "false"
1742-
volumes:
1743-
- .:/arrow:delegated
1744-
command: >
1745-
/bin/bash -c "
1746-
/arrow/ci/scripts/r_sanitize.sh /arrow"
1747-
1748-
r-clang-ubsan:
1749-
image: ${REPO}:r-rhub-clang-ubsan-devel-latest
1750-
build:
1751-
context: .
1752-
dockerfile: ci/docker/linux-r.dockerfile
1753-
cache_from:
1754-
- ${REPO}:r-rhub-clang-ubsan-devel-latest
1755-
args:
1756-
base: rhub/clang-ubsan
1699+
base: ${R_ORG}/${R_IMAGE}:${R_TAG}
17571700
cmake: ${CMAKE}
17581701
r_dev: ${ARROW_R_DEV}
17591702
r_bin: R

0 commit comments

Comments
 (0)