Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions ci/scripts/r_docker_configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,19 @@ if [ "$ARROW_S3" == "ON" ] || [ "$ARROW_R_DEV" == "TRUE" ]; then
fi
fi

# Install patch if it doesn't already exist
if [ ! $(command -v patch) ]; then
if [ "`which dnf`" ]; then
dnf install -y patch
elif [ "`which yum`" ]; then
yum install -y patch
elif [ "`which zypper`" ]; then
zypper install -y patch
else
apt-get update
apt-get install -y patch
fi
fi
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not strictly necessary (see below where we disable snappy if we can't find patch), but it makes sure that we do have patch available so we do exercise this code in the sanitizer in our CI


# Workaround for html help install failure; see https://github.com/r-lib/devtools/issues/2084#issuecomment-530912786
Rscript -e 'x <- file.path(R.home("doc"), "html"); if (!file.exists(x)) {dir.create(x, recursive=TRUE); file.copy(system.file("html/R.css", package="stats"), x)}'
30 changes: 30 additions & 0 deletions cpp/build-support/snappy-UBSAN.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

diff --git a/snappy.cc b/snappy.cc
index 79dc0e8..2b5e662 100644
--- a/snappy.cc
+++ b/snappy.cc
@@ -348,7 +348,7 @@ static inline bool Copy64BytesWithPatternExtension(char* dst, size_t offset) {
if (SNAPPY_PREDICT_TRUE(offset < 16)) {
if (SNAPPY_PREDICT_FALSE(offset == 0)) return false;
// Extend the pattern to the first 16 bytes.
- for (int i = 0; i < 16; i++) dst[i] = dst[i - offset];
+ for (int i = 0; i < 16; i++) dst[i] = (dst - offset)[i];
// Find a multiple of pattern >= 16.
static std::array<uint8_t, 16> pattern_sizes = []() {
std::array<uint8_t, 16> res;
9 changes: 9 additions & 0 deletions cpp/cmake_modules/ThirdpartyToolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,14 @@ else()
"https://github.com/google/snappy/archive/${ARROW_SNAPPY_BUILD_VERSION}.tar.gz"
"https://github.com/ursa-labs/thirdparty/releases/download/latest/snappy-${ARROW_SNAPPY_BUILD_VERSION}.tar.gz"
)

# This can be removed when https://github.com/google/snappy/pull/148 is released
# Some platforms don't have patch, but this is probably ok to skip
find_program(patch "patch")
if(patch)
set(SNAPPY_PATCH_COMMAND "patch" "snappy.cc"
"${CMAKE_SOURCE_DIR}/build-support/snappy-UBSAN.patch")
endif()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Snappy works without the patch, though it has a UBSAN error, so this patches if we can and moves on if not so we don't break.

endif()
endif()

Expand Down Expand Up @@ -1039,6 +1047,7 @@ macro(build_snappy)
URL ${SNAPPY_SOURCE_URL}
URL_HASH "SHA256=${ARROW_SNAPPY_BUILD_SHA256_CHECKSUM}"
CMAKE_ARGS ${SNAPPY_CMAKE_ARGS}
PATCH_COMMAND ${SNAPPY_PATCH_COMMAND}
BUILD_BYPRODUCTS "${SNAPPY_STATIC_LIB}")

file(MAKE_DIRECTORY "${SNAPPY_PREFIX}/include")
Expand Down
1 change: 1 addition & 0 deletions cpp/thirdparty/versions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ ARROW_RAPIDJSON_BUILD_VERSION=1a803826f1197b5e30703afe4b9c0e7dd48074f5
ARROW_RAPIDJSON_BUILD_SHA256_CHECKSUM=0b6b780b6c534bfb0b23d29910bfe361e486bcfeaf106db8bc8995792072905a
ARROW_RE2_BUILD_VERSION=2021-02-02
ARROW_RE2_BUILD_SHA256_CHECKSUM=1396ab50c06c1a8885fb68bf49a5ecfd989163015fd96699a180d6414937f33f
# 1.1.9 is patched to implement https://github.com/google/snappy/pull/148 if this is bumped, remove the patch
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tried to flag this, and if we pursue this path, I'll make a Jira that points to each of these lines that need to be deleted when > 1.1.9 is released

ARROW_SNAPPY_BUILD_VERSION=1.1.9
ARROW_SNAPPY_BUILD_SHA256_CHECKSUM=75c1fbb3d618dd3a0483bff0e26d0a92b495bbe5059c8b4f1c962b478b6e06e7
# There is a bug in GCC < 4.9 with Snappy 1.1.9, so revert to 1.1.8 for those (ARROW-14661)
Expand Down
6 changes: 6 additions & 0 deletions r/inst/build_arrow_static.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ else
ARROW_DEFAULT_PARAM="OFF"
fi

# Snappy 1.1.9 is patched to implement https://github.com/google/snappy/pull/148 but some platforms don't have
# patch available, so disable snappy in those cases. If the snappy version is bumped, we should remove this.
if [ ! $(command -v patch) ]; then
ARROW_WITH_SNAPPY=OFF
fi
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For our CI this should not be hit, but is important incase CRAN happens to not have patch, it will disable snappy so we don't get a sanitizer error there.


mkdir -p "${BUILD_DIR}"
pushd "${BUILD_DIR}"
${CMAKE} -DARROW_BOOST_USE_SHARED=OFF \
Expand Down