You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/05/04 09:36:29 UTC

[GitHub] [arrow] pitrou commented on a change in pull request #10237: ARROW-12571: [R][CI] Run nightly R with valgrind

pitrou commented on a change in pull request #10237:
URL: https://github.com/apache/arrow/pull/10237#discussion_r625619463



##########
File path: ci/scripts/r_valgrind.sh
##########
@@ -0,0 +1,81 @@
+#!/usr/bin/env bash
+# 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.
+
+set -ex
+
+: ${R_BIN:=RDvalgrind}
+
+printenv
+
+source_dir=${1}/r
+
+${R_BIN} CMD INSTALL ${source_dir}
+pushd ${source_dir}/tests
+
+export TEST_R_WITH_ARROW=TRUE
+${R_BIN} --vanilla -d "valgrind --tool=memcheck --leak-check=full --track-origins=yes" -f testthat.R > testthat.out 2>&1 || true
+
+# TODO: examples? vignettes? R CMD check with valgrind on?
+
+cat testthat.out
+
+# Check the valgrind output
+# We might also considering using the greps that LibthGBM uses:
+# https://github.com/microsoft/LightGBM/blob/fa6d356555f9ef888acf5f5e259dca958ca24f6d/.ci/test_r_package_valgrind.sh#L20-L85
+
+# No errors at all

Review comment:
       You should use `valgrind --error-exitcode=1` instead of grepping.

##########
File path: ci/scripts/r_valgrind.sh
##########
@@ -0,0 +1,81 @@
+#!/usr/bin/env bash
+# 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.
+
+set -ex
+
+: ${R_BIN:=RDvalgrind}
+
+printenv
+
+source_dir=${1}/r
+
+${R_BIN} CMD INSTALL ${source_dir}
+pushd ${source_dir}/tests
+
+export TEST_R_WITH_ARROW=TRUE
+${R_BIN} --vanilla -d "valgrind --tool=memcheck --leak-check=full --track-origins=yes" -f testthat.R > testthat.out 2>&1 || true
+
+# TODO: examples? vignettes? R CMD check with valgrind on?
+
+cat testthat.out
+
+# Check the valgrind output
+# We might also considering using the greps that LibthGBM uses:
+# https://github.com/microsoft/LightGBM/blob/fa6d356555f9ef888acf5f5e259dca958ca24f6d/.ci/test_r_package_valgrind.sh#L20-L85
+
+# No errors at all
+if [[ "$(grep -c 'ERROR SUMMARY: 0 errors' testthat.out)" == 1 ]]; then
+  no_errors=true
+else
+  no_errors=false
+fi
+
+# This error happens in our CI when there is a `skip()` of any sort. It does not show up on the cran 
+# logs so we should be able to ignore it.
+# ==273== Conditional jump or move depends on uninitialised value(s)
+# ==273==    at 0x49CFFB6: gregexpr_Regexc (grep.c:2413)
+# ==273==    by 0x49D2CB2: do_regexpr (grep.c:3050)
+# ==273==    by 0x49A08C8: bcEval (eval.c:7115)
+# ==273==    by 0x498BF52: Rf_eval (eval.c:727)
+# ==273==    by 0x498ECC1: R_execClosure (eval.c:1897)
+# ==273==    by 0x498E974: Rf_applyClosure (eval.c:1823)
+# ==273==    by 0x49A04FC: bcEval (eval.c:7083)
+# ==273==    by 0x498BF52: Rf_eval (eval.c:727)
+# ==273==    by 0x498BA9E: forcePromise (eval.c:555)
+# ==273==    by 0x4996C1B: FORCE_PROMISE (eval.c:5136)
+# ==273==    by 0x4996DD6: getvar (eval.c:5177)
+# ==273==    by 0x499DA15: bcEval (eval.c:6867)
+# ==273==  Uninitialised value was created by a stack allocation
+# ==273==    at 0x49CFAB5: gregexpr_Regexc (grep.c:2343)
+# ==273==
+if [[   "$(grep -c 'ERROR SUMMARY: 2 errors' testthat.out)" = 1 &&
+  "$(grep -c 'Conditional jump or move depends on uninitialised value' testthat.out)" = 1 &&
+  "$(grep -c 'Uninitialised value was created by a stack allocation' testthat.out)" = 1 ]]; then

Review comment:
       We should use a Valgrind suppressions file instead of grepping:
   https://stackoverflow.com/questions/17159578/generating-suppressions-for-memory-leaks
   

##########
File path: r/tests/testthat/test-compute-aggregate.R
##########
@@ -37,7 +37,8 @@ test_that("sum.Array", {
 
   floats <- c(floats, NA)
   na <- Array$create(floats)
-  expect_identical(as.numeric(sum(na)), sum(floats))
+  # expect_identical(as.numeric(sum(na)), sum(floats))
+  expect_identical(as.numeric(sum(na)), NA_real_)

Review comment:
       Why these changes? If they have a specific purpose, there should be a comment explaining them.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org