Skip to content

Commit 2226e3d

Browse files
authored
Merge pull request #72 from r-spatial/dewey-dev
Fix CRAN check errors, update actions
2 parents 83a1f4c + e64b152 commit 2226e3d

File tree

10 files changed

+69
-32
lines changed

10 files changed

+69
-32
lines changed

.github/workflows/R-CMD-check.yaml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,15 @@ jobs:
2121
config:
2222
- {os: windows-latest, r: '3.6'}
2323
- {os: macOS-latest, r: '3.6'}
24-
- {os: ubuntu-16.04, r: '3.6'}
25-
- {os: ubuntu-18.04, r: '3.6'}
2624
- {os: windows-latest, r: '4.0'}
2725
- {os: macOS-latest, r: '4.0'}
28-
- {os: ubuntu-16.04, r: '4.0'}
29-
- {os: ubuntu-18.04, r: '4.0'}
26+
- {os: ubuntu-16.04, r: '4.0', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
27+
- {os: ubuntu-18.04, r: '4.0', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}
28+
- {os: ubuntu-18.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"}
3029

3130
env:
3231
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
33-
CRAN: ${{ matrix.config.cran }}
32+
RSPM: ${{ matrix.config.rspm }}
3433

3534
steps:
3635
- uses: actions/checkout@v1
@@ -77,6 +76,16 @@ jobs:
7776
run: rcmdcheck::rcmdcheck(args = "--no-manual", error_on = "warning", check_dir = "check")
7877
shell: Rscript {0}
7978

79+
- name: Show install output
80+
if: always()
81+
run: find check -name '00install.out*' -exec cat '{}' \; || true
82+
shell: bash
83+
84+
- name: Show testthat output
85+
if: always()
86+
run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true
87+
shell: bash
88+
8089
- name: Upload check results
8190
if: failure()
8291
uses: actions/upload-artifact@master

.github/workflows/pkgdown.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ jobs:
3030

3131
- name: Install dependencies
3232
run: |
33-
install.packages("remotes")
3433
remotes::install_deps(dependencies = TRUE)
3534
remotes::install_dev("pkgdown")
3635
shell: Rscript {0}
@@ -39,5 +38,7 @@ jobs:
3938
run: R CMD INSTALL .
4039

4140
- name: Deploy package
42-
run: pkgdown::deploy_to_branch(new_process = FALSE)
43-
shell: Rscript {0}
41+
run: |
42+
git config --local user.email "[email protected]"
43+
git config --local user.name "GitHub Actions"
44+
Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)'

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: s2
22
Title: Spherical Geometry Operators Using the S2 Geometry Library
3-
Version: 1.0.1.9000
3+
Version: 1.0.2
44
Authors@R: c(
55
person(given = "Dewey",
66
family = "Dunnington",

NEWS.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# s2 (development version)
1+
# s2 1.0.2
2+
3+
* Fixed CRAN check errors (#71, #75, #72).
24

35
# s2 1.0.1
46

R/s2-geography.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#' of most functions in the s2 package so that you can use other objects with
1010
#' an unambiguious interpretation as a geography vector. Geography vectors
1111
#' have a minimal [vctrs][vctrs::vctrs-package] implementation, so you can
12-
#' use these objects in tibble and other packages that use the vctrs
12+
#' use these objects in tibble, dplyr, and other packages that use the vctrs
1313
#' framework.
1414
#'
1515
#' @param x An object that can be converted to an s2_geography vector

data-raw/update-s2.R

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,17 @@ print_next <- function() {
8181
)
8282
cli::cat_bullet(
8383
"Fix zero-length array warnings under -Wpedantic by inserting __extension__ at the beginning ",
84-
"of expressions declaring them (s2region_coverer.h#251, util/gtl/compact_array.h#124)"
84+
"of expressions declaring them (s2region_coverer.h#271)"
8585
)
86+
cli::cat_bullet(
87+
"Fix compact_array zero-length array warning by disabling inline elements on gcc ",
88+
"(util/gtl/compact_array.h#89)"
89+
)
90+
cli::cat_bullet(
91+
"Fix sanitizer error for compact_array when increasing the size of a zero-length array ",
92+
"by wrapping util/gtl/compact_array.h#396-397 with if (old_capacity > 0) {...}"
93+
)
94+
8695
cli::cat_bullet("Remove extra semi-colon at s2boolean_operation.h#376")
8796
cli::cat_bullet("Remove extra semi-colons because of FROMHOST_TYPE_MAP macro (utils/endian/endian.h#565)")
8897
cli::cat_bullet(

inst/include/s2/s2region_coverer.h

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#ifndef S2_S2REGION_COVERER_H_
1919
#define S2_S2REGION_COVERER_H_
2020

21+
#include <cstddef>
22+
#include <new>
2123
#include <queue>
2224
#include <utility>
2325
#include <vector>
@@ -245,9 +247,27 @@ class S2RegionCoverer {
245247

246248
private:
247249
struct Candidate {
250+
void* operator new(std::size_t size, std::size_t max_children) {
251+
return ::operator new (size + max_children * sizeof(Candidate *));
252+
}
253+
254+
void operator delete(void* p) {
255+
::operator delete (p);
256+
}
257+
258+
Candidate(const S2Cell& cell, const std::size_t max_children)
259+
: cell(cell), is_terminal(max_children == 0) {
260+
std::fill_n(&children[0], max_children,
261+
absl::implicit_cast<Candidate*>(nullptr));
262+
}
263+
264+
// Default destructor is fine; Candidate* is trivially destructible.
265+
// children must be deleted by DeleteCandidate.
266+
~Candidate() = default;
267+
248268
S2Cell cell;
249269
bool is_terminal; // Cell should not be expanded further.
250-
int num_children; // Number of children that intersect the region.
270+
int num_children = 0; // Number of children that intersect the region.
251271
__extension__ Candidate* children[0]; // Actual size may be 0, 4, 16, or 64 elements.
252272
};
253273

inst/include/s2/util/gtl/compact_array.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,10 @@ class compact_array_base {
8686
#endif
8787

8888
// Opportunistically consider allowing inlined elements.
89-
#if defined(_LP64) && defined(__GNUC__)
89+
// dd: this has to be disabled to pass CRAN checks, since there is a
90+
// (potentially) zero-length array that is not the last element of the class (so
91+
// this can't be silenced using __extension__)
92+
#if defined(_LP64) && defined(__GNUC__) && false
9093
// With 64-bit pointers, our approach is to form a 16-byte struct:
9194
// [5 bytes for size, capacity, is_exponent and is_inlined]
9295
// [3 bytes of padding or inlined elements]
@@ -393,8 +396,13 @@ class compact_array_base {
393396
value_allocator_type allocator;
394397

395398
T* new_ptr = allocator.allocate(capacity());
396-
memcpy(new_ptr, Array(), old_capacity * sizeof(T));
397-
allocator.deallocate(Array(), old_capacity);
399+
// dd: this modification fixes a ASAN/UBSAN error, because
400+
// when old_capacity is 0, Array() is nullptr, which is UB
401+
// for memcpy.
402+
if (old_capacity > 0) {
403+
memcpy(new_ptr, Array(), old_capacity * sizeof(T));
404+
allocator.deallocate(Array(), old_capacity);
405+
}
398406

399407
SetArray(new_ptr);
400408
}

man/as_s2_geography.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/s2/s2region_coverer.cc

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -106,21 +106,9 @@ S2RegionCoverer::Candidate* S2RegionCoverer::NewCandidate(const S2Cell& cell) {
106106
}
107107
}
108108
}
109-
size_t children_size = 0;
110-
if (!is_terminal) {
111-
children_size = sizeof(Candidate*) << max_children_shift();
112-
}
113-
Candidate* candidate = static_cast<Candidate*>(
114-
::operator new(sizeof(Candidate) + children_size));
115-
candidate->cell = cell;
116-
candidate->is_terminal = is_terminal;
117-
candidate->num_children = 0;
118-
if (!is_terminal) {
119-
std::fill_n(&candidate->children[0], 1 << max_children_shift(),
120-
absl::implicit_cast<Candidate*>(nullptr));
121-
}
122109
++candidates_created_counter_;
123-
return candidate;
110+
const std::size_t max_children = is_terminal ? 0 : 1 << max_children_shift();
111+
return new (max_children) Candidate(cell, max_children);
124112
}
125113

126114
void S2RegionCoverer::DeleteCandidate(Candidate* candidate,
@@ -129,7 +117,7 @@ void S2RegionCoverer::DeleteCandidate(Candidate* candidate,
129117
for (int i = 0; i < candidate->num_children; ++i)
130118
DeleteCandidate(candidate->children[i], true);
131119
}
132-
::operator delete(candidate);
120+
delete candidate;
133121
}
134122

135123
int S2RegionCoverer::ExpandChildren(Candidate* candidate,

0 commit comments

Comments
 (0)