More issues identified by r-hub/containers
On ubuntu-clang:
# export DOCKER_DEFAULT_PLATFORM=linux/amd64
# docker run --rm -it -v $(pwd):/pkg ghcr.io/r-hub/containers/ubuntu-clang bash
# R CMD build /pkg
# cp s2_1.1.7.9000.tar.gz /check
# apt-get install cmake libabsl-dev
# r-check
File ‘s2/libs/s2.so’:
Found ‘_ZSt4cerr’, possibly from ‘std::cerr’ (C++)
Object: ‘../tools/dist/lib/libabsl_flags_config.a’
Found ‘_exit’, possibly from ‘_exit’ (C)
Object: ‘../tools/dist/lib/libabsl_log_internal_message.a’
Found ‘abort’, possibly from ‘abort’ (C)
Objects: ‘../tools/dist/lib/libabsl_log_internal_message.a’,
‘../tools/dist/lib/libabsl_raw_logging_internal.a’,
‘../tools/dist/lib/libabsl_symbolize.a’
Found ‘exit’, possibly from ‘exit’ (C)
Object: ‘../tools/dist/lib/libabsl_flags_reflection.a’
Found ‘stderr’, possibly from ‘stderr’ (C)
Objects: ‘../tools/dist/lib/libabsl_log_internal_globals.a’,
‘../tools/dist/lib/libabsl_str_format_internal.a’
https://r-hub.github.io/containers/
https://r-hub.github.io/containers/local.html
I wonder if we can get around this one by building the static libraries in a temporary directory instead of within the tools/ directory (surely we're allowed to have symbols like this when linking against system libraries?)
This one is a new change from r-devel and I don't think we'll be able to get around it (well, there are workarounds, but none that are in good faith with the spirit of the rule). The only way to avoid this would be to require a user to build/install a suitable version of Abseil themselves, and that is not trivial for the average user.
We see this now on mac-os, here https://cran.r-project.org/web/checks/check_results_s2.html - shall I contact simon to see if he can adopt absl as part of his build train, like it is in rtools for windows?
I think so - I'm honestly just curious what the reccomended solution is here otherwise. I don't have the bandwidth to go through and remove all references to abort and stdderr from our vendored Abseil (and this is also a security issue: it means I can't keep Abseil up to date if a patch release is issued for that version of Abseil). I also think this is pointless: if we link to system there's an exactly equal probability that we're going to write to stdout or abort (we don't, because we're careful to avoid the code paths in S2 that might trigger that).
More things to fix:
fedora-xx + clang20 with libcpp:
^
1 warning generated.
2 warnings generated.
2 warnings generated.
ar rcs s2/libs2static.a s2/encoded_s2cell_id_vector.o s2/encoded_s2point_vector.o s2/encoded_s2shape_index.o s2/encoded_string_vector.o s2/id_set_lexicon.o s2/mutable_s2shape_index.o s2/r2rect.o s2/s1angle.o s2/s1chord_angle.o s2/s1interval.o s2/s2boolean_operation.o s2/s2buffer_operation.o s2/s2builder_graph.o s2/s2builder.o s2/s2builderutil_closed_set_normalizer.o s2/s2builderutil_find_polygon_degeneracies.o s2/s2builderutil_get_snapped_winding_delta.o s2/s2builderutil_lax_polygon_layer.o s2/s2builderutil_lax_polyline_layer.o s2/s2builderutil_s2point_vector_layer.o s2/s2builderutil_s2polygon_layer.o s2/s2builderutil_s2polyline_layer.o s2/s2builderutil_s2polyline_vector_layer.o s2/s2builderutil_snap_functions.o s2/s2cap.o s2/s2cell_id.o s2/s2cell_index.o s2/s2cell_union.o s2/s2cell.o s2/s2centroids.o s2/s2closest_cell_query.o s2/s2closest_edge_query.o s2/s2closest_point_query.o s2/s2contains_vertex_query.o s2/s2convex_hull_query.o s2/s2coords.o s2/s2crossing_edge_query.o s2/s2debug.o s2/s2earth.o s2/s2edge_clipping.o s2/s2edge_crosser.o s2/s2edge_crossings.o s2/s2edge_distances.o s2/s2edge_tessellator.o s2/s2error.o s2/s2furthest_edge_query.o s2/s2hausdorff_distance_query.o s2/s2latlng_rect_bounder.o s2/s2latlng_rect.o s2/s2latlng.o s2/s2lax_loop_shape.o s2/s2lax_polygon_shape.o s2/s2lax_polyline_shape.o s2/s2loop_measures.o s2/s2loop.o s2/s2max_distance_targets.o s2/s2measures.o s2/s2memory_tracker.o s2/s2metrics.o s2/s2min_distance_targets.o s2/s2padded_cell.o s2/s2point_compression.o s2/s2point_region.o s2/s2pointutil.o s2/s2polygon.o s2/s2polyline_alignment.o s2/s2polyline_measures.o s2/s2polyline_simplifier.o s2/s2polyline.o s2/s2predicates.o s2/s2projections.o s2/s2r2rect.o s2/s2region_coverer.o s2/s2region_intersection.o s2/s2region_term_indexer.o s2/s2region_union.o s2/s2region.o s2/s2shape_index_buffered_region.o s2/s2shape_index_measures.o s2/s2shape_index.o s2/s2shape_measures.o s2/s2shape_nesting_query.o s2/s2shapeutil_build_polygon_boundaries.o s2/s2shapeutil_coding.o s2/s2shapeutil_contains_brute_force.o s2/s2shapeutil_conversion.o s2/s2shapeutil_edge_iterator.o s2/s2shapeutil_get_reference_point.o s2/s2shapeutil_visit_crossing_edge_pairs.o s2/s2text_format.o s2/s2wedge_relations.o s2/s2winding_operation.o s2/util/bits/bit-interleave.o s2/util/coding/coder.o s2/util/coding/varint.o s2/util/math/exactfloat/exactfloat.o s2/util/math/mathutil.o s2/util/units/length-units.o
clang++-20 -std=gnu++17 -shared -L/usr/local/clang/lib64 -L/usr/local/clang20/lib -L/usr/local/clang20/lib/x86_64-unknown-linux-gnu -L/usr/local/lib64 -L/usr/local/clang20/lib/clang/20/lib/x86_64-unknown-linux-gnu -o s2.so cpp-compat.o s2-accessors.o s2-bounds.o s2-cell.o s2-cell-union.o s2-constructors-formatters.o s2-predicates.o s2-transformers.o init.o RcppExports.o s2-geography.o s2-lnglat.o s2-matrix.o wk-impl.o s2geography/accessors-geog.o s2geography/accessors.o s2geography/build.o s2geography/coverings.o s2geography/distance.o s2geography/geography.o s2geography/linear-referencing.o s2geography/predicates.o -Ls2 -ls2static -labsl_flags_internal -labsl_flags_marshalling -labsl_flags_reflection -labsl_flags_private_handle_accessor -labsl_flags_commandlineflag -labsl_flags_commandlineflag_internal -labsl_flags_config -labsl_flags_program_name -labsl_raw_hash_set -labsl_hashtablez_sampler -labsl_log_internal_check_op -labsl_log_internal_conditions -labsl_log_internal_message -labsl_examine_stack -labsl_log_internal_format -labsl_log_internal_proto -labsl_log_internal_nullguard -labsl_log_internal_log_sink_set -labsl_log_internal_globals -labsl_log_globals -labsl_hash -labsl_city -labsl_bad_variant_access -labsl_low_level_hash -labsl_vlog_config_internal -labsl_log_internal_fnmatch -labsl_log_sink -labsl_log_entry -labsl_status -labsl_cord -labsl_cordz_info -labsl_cord_internal -labsl_cordz_functions -labsl_exponential_biased -labsl_cordz_handle -labsl_synchronization -labsl_graphcycles_internal -labsl_kernel_timeout_internal -labsl_time -labsl_civil_time -labsl_time_zone -labsl_crc_cord_state -labsl_crc32c -labsl_crc_internal -labsl_crc_cpu_detect -labsl_bad_optional_access -labsl_stacktrace -labsl_strerror -labsl_str_format_internal -labsl_symbolize -labsl_debugging_internal -labsl_demangle_internal -labsl_malloc_internal -labsl_strings -labsl_strings_internal -labsl_string_view -labsl_base -lrt -labsl_spinlock_wait -labsl_int128 -labsl_throw_delegate -labsl_raw_logging_internal -labsl_log_severity -lssl -lcrypto
make[1]: Leaving directory '/data/gannet/ripley/R/packages/tests-clang/s2/src'
make[1]: Entering directory '/data/gannet/ripley/R/packages/tests-clang/s2/src'
make[1]: Leaving directory '/data/gannet/ripley/R/packages/tests-clang/s2/src'
installing to /data/gannet/ripley/R/packages/tests-clang/s2.Rcheck/00LOCK-s2/00new/s2/libs
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
*** copying figures
** building package indices
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for ‘s2’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/data/gannet/ripley/R/packages/tests-clang/s2.Rcheck/00LOCK-s2/00new/s2/libs/s2.so':
/data/gannet/ripley/R/packages/tests-clang/s2.Rcheck/00LOCK-s2/00new/s2/libs/s2.so: undefined symbol: _ZN4absl12lts_2024011614flags_internal13AbslParseFlagENSt3__117basic_string_viewIcNS2_11char_traitsIcEEEEPxPNS2_12basic_stringIcS5_NS2_9allocatorIcEEEE
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/data/gannet/ripley/R/packages/tests-clang/s2.Rcheck/s2’
gcc >= 14 (Debian and Windows). These are a bit funny because they're using C++14 (pretty sure we need + specify 17 but maybe not well enough, and maybe we need a stricter minimum version)
Found the following significant warnings:
/usr/include/c++/14/bits/stl_algobase.h:766:30: warning: ‘void* __builtin_memmove(void*, const void*, long unsigned int)’ offset [-328, -5] is out of the bounds [0, 340] of object ‘exact_mantissa’ with type ‘absl::lts_20220623::strings_internal::BigUnsigned<84>’ [-Warray-bounds=]
/usr/include/c++/14/bits/stl_algobase.h:766:30: warning: ‘void* __builtin_memmove(void*, const void*, long unsigned int)’ offset [-328, -5] is out of the bounds [0, 340] of object ‘rhs’ with type ‘absl::lts_20220623::strings_internal::BigUnsigned<84>’ [-Warray-bounds=]
See ‘/home/hornik/tmp/R.check/r-devel-gcc/Work/PKGS/s2.Rcheck/00install.out’ for details.
* used C compiler: ‘gcc-14 (Debian 14.2.0-19) 14.2.0’
* used C++ compiler: ‘g++-14 (Debian 14.2.0-19) 14.2.0’
Right, we also got a
Please correct before 2025-05-26 to safely retain your package on CRAN.
Two more:
> # s2_point_on_surface guarantees a point on surface
> # Note: this is not the same as st_point_on_surface
> s2_centroid("POLYGON ((0 0, 10 0, 1 1, 0 10, 0 0))")
<geodesic s2_geography[1] with CRS=OGC:CRS84>
[1] POINT (2.00377112 2.00234355)
> s2_point_on_surface("POLYGON ((0 0, 10 0, 1 1, 0 10, 0 0))")
s2/s2region_coverer.cc:134:52: runtime error: index 0 out of bounds for type 'Candidate *[18446744073709551616]'
...this one is because the sanitizer doesn't understand the zero length member at the end of the candidate struct.
Another one, this one internal to Abseil I think
> # returns the closest point on x to y
> s2_closest_point(
+ "POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))",
+ "POINT (0 90)" # north pole!
+ )
/usr/include/absl/container/internal/raw_hash_set.h:891:47: runtime error: load of null pointer of type 'GenerationType'
#0 0x7f846d91f403 in absl::lts_20240116::container_internal::CommonFieldsGenerationInfoEnabled::generation() const /usr/include/absl/container/internal/raw_hash_set.h:891
#1 0x7f846d91f403 in bool absl::lts_20240116::container_internal::HashSetResizeHelper::InitializeSlots<std::allocator<char>, 8ul, true,
We also have a problem where some gccs are compiling with C++14 (and need to be C++17, which is causing an issue with constexpr):
g++-14 -fsanitize=address,undefined,bounds-strict -fno-omit-frame-pointer -std=gnu++17 -I"/home/hornik/tmp/R-d-gcc-xtra/include" -DNDEBUG -I../src -DSTRICT_R_HEADERS -I'/home/hornik/tmp/CRAN_special_gcc-san/Library/Rcpp/include' -I'/home/hornik/tmp/CRAN_special_gcc-san/Library/wk/include' -I/usr/local/include -DUSE_TYPE_CHECKING_STRICT -D_FORTIFY_SOURCE=3 -pthread -fpic -g -O2 -Wall -pedantic -mtune=native -Wno-ignored-attributes -Wno-deprecated-declarations -Wno-stringop-truncation -c s2-cell-union.cpp -o s2-cell-union.o
In file included from ../src/s2/s2shape_index.h:66,
from ../src/s2/s2distance_target.h:27,
from ../src/s2/s2closest_edge_query_base.h:42,
from ../src/s2/s2closest_edge_query.h:34,
from s2/s2shape_index_buffered_region.h:29,
from s2-cell-union.cpp:7:
../src/s2/util/gtl/compact_array.h: In instantiation of ‘class gtl::compact_array_base<S2ClippedShape, std::allocator<S2ClippedShape> >’:
../src/s2/util/gtl/compact_array.h:542:7: required from ‘class gtl::compact_array<S2ClippedShape>’
542 | class compact_array : public compact_array_base<T, A> {
| ^~~~~~~~~~~~~
../src/s2/s2shape_index.h:192:21: required from here
192 | S2ClippedShapeSet shapes_;
| ^~~~~~~
../src/s2/util/gtl/compact_array.h:127:28: warning: ISO C++ forbids zero-size array [-Wpedantic]
127 | char inlined_elements_[3 - kUnusedPaddingBytes];
| ~~^~~~~~~~~~~~~~~~~~~~~
../src/s2/util/gtl/compact_array.h:127:8: warning: zero-size array member ‘gtl::compact_array_base<S2ClippedShape, std::allocator<S2ClippedShape> >::inlined_elements_’ not at end of ‘class gtl::compact_array_base<S2ClippedShape, std::allocator<S2ClippedShape> >’ [-Wpedantic]
127 | char inlined_elements_[3 - kUnusedPaddingBytes];
| ^~~~~~~~~~~~~~~~~
../src/s2/util/gtl/compact_array.h:65:7: note: in the definition of ‘class gtl::compact_array_base<S2ClippedShape, std::allocator<S2ClippedShape> >’
65 | class compact_array_base {
| ^~~~~~~~~~~~~~~~~~
../src/s2/util/gtl/compact_array.h: In instantiation of ‘class gtl::compact_array<S2ClippedShape>’:
../src/s2/s2shape_index.h:192:21: required from here
192 | S2ClippedShapeSet shapes_;
| ^~~~~~~
../src/s2/util/gtl/compact_array.h:127:8: warning: zero-size array member ‘gtl::compact_array_base<S2ClippedShape, std::allocator<S2ClippedShape> >::inlined_elements_’ not at end of ‘class gtl::compact_array<S2ClippedShape>’ [-Wpedantic]
127 | char inlined_elements_[3 - kUnusedPaddingBytes];
| ^~~~~~~~~~~~~~~~~
../src/s2/util/gtl/compact_array.h:542:7: note: in the definition of ‘class gtl::compact_array<S2ClippedShape>’
542 | class compact_array : public compact_array_base<T, A> {
| ^~~~~~~~~~~~~
In file included from /usr/include/absl/log/internal/check_impl.h:20,
from /usr/include/absl/log/check.h:37,
from ../src/s2/base/logging.h:21,
from s2/s2cell_id.h:37,
from s2-cell-union.cpp:2:
../src/s2/encoded_uint_vector.h: In instantiation of ‘T s2coding::EncodedUintVector<T>::operator[](int) const [with T = long long unsigned int]’:
../src/s2/encoded_string_vector.h:154:47: required from here
154 | uint64 start = (i == 0) ? 0 : offsets_[i - 1];
| ^
../src/s2/encoded_uint_vector.h:256:25: warning: comparison of integer expressions of different signedness: ‘int’ and ‘const uint32’ {aka ‘const unsigned int’} [-Wsign-compare]
256 | S2_DCHECK(i >= 0 && i < size_);
| ~~^~~~~~~
../src/s2/encoded_uint_vector.h:256:3: note: in expansion of macro ‘S2_DCHECK’
256 | S2_DCHECK(i >= 0 && i < size_);
| ^~~~~~~~~
../src/s2/encoded_uint_vector.h: In instantiation of ‘T s2coding::GetUintWithLength(const char*, int) [with T = long long unsigned int]’:
../src/s2/encoded_uint_vector.h:257:30: required from ‘T s2coding::EncodedUintVector<T>::operator[](int) const [with T = long long unsigned int]’
257 | return GetUintWithLength<T>(data_ + i * len_, len_);
| ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
../src/s2/encoded_string_vector.h:154:47: required from here
154 | uint64 start = (i == 0) ? 0 : offsets_[i - 1];
| ^
../src/s2/encoded_uint_vector.h:157:35: warning: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Wsign-compare]
157 | S2_DCHECK(length >= 0 && length <= sizeof(T));
| ~~~~~~~^~~~~~~~~~~~
../src/s2/encoded_uint_vector.h:157:3: note: in expansion of macro ‘S2_DCHECK’
157 | S2_DCHECK(length >= 0 && length <= sizeof(T));
| ^~~~~~~~~
In file included from /usr/include/absl/container/internal/raw_hash_set.h:213,
from /usr/include/absl/container/flat_hash_set.h:45,
from ../src/s2/s2closest_edge_query_base.h:33:
/usr/include/absl/container/internal/hash_policy_traits.h: In instantiation of ‘static const absl::debian7::container_internal::PolicyFunctions& absl::debian7::container_internal::raw_hash_set<Policy, Hash, Eq, Alloc>::GetPolicyFunctions() [with Policy = absl::debian7::container_internal::FlatHashSetPolicy<s2shapeutil::ShapeEdgeId>; Hash = absl::debian7::hash_internal::Hash<s2shapeutil::ShapeEdgeId>; Eq = std::equal_to<s2shapeutil::ShapeEdgeId>; Alloc = std::allocator<s2shapeutil::ShapeEdgeId>]’:
/usr/include/absl/container/internal/raw_hash_set.h:2919:53: required from ‘void absl::debian7::container_internal::raw_hash_set<Policy, Hash, Eq, Alloc>::clear() [with Policy = absl::debian7::container_internal::FlatHashSetPolicy<s2shapeutil::ShapeEdgeId>; Hash = absl::debian7::hash_internal::Hash<s2shapeutil::ShapeEdgeId>; Eq = std::equal_to<s2shapeutil::ShapeEdgeId>; Alloc = std::allocator<s2shapeutil::ShapeEdgeId>]’
2919 | ClearBackingArray(common(), GetPolicyFunctions(), /*reuse=*/cap < 128,
| ~~~~~~~~~~~~~~~~~~^~
../src/s2/s2closest_edge_query_base.h:560:22: required from ‘void S2ClosestEdgeQueryBase<Distance>::FindClosestEdgesInternal(Target*, const Options&) [with Distance = S2MinDistance; Target = S2DistanceTarget<S2MinDistance>]’
560 | tested_edges_.clear();
| ~~~~~~~~~~~~~~~~~~~^~
../src/s2/s2closest_edge_query_base.h:537:3: required from ‘void S2ClosestEdgeQueryBase<Distance>::FindClosestEdges(Target*, const Options&, std::vector<Result>*) [with Distance = S2MinDistance; Target = S2DistanceTarget<S2MinDistance>]’
537 | FindClosestEdgesInternal(target, options);
| ^~~~~~~~~~~~~~~~~~~~~~~~
../src/s2/s2closest_edge_query.h:409:25: required from here
409 | base_.FindClosestEdges(target, options_, results);
| ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/absl/container/internal/raw_hash_set.h:4052:56: in ‘constexpr’ expansion of ‘absl::debian7::container_internal::hash_policy_traits<absl::debian7::container_internal::FlatHashSetPolicy<s2shapeutil::ShapeEdgeId>, void>::get_hash_slot_fn<absl::debian7::hash_internal::Hash<s2shapeutil::ShapeEdgeId> >()’
/usr/include/absl/container/internal/hash_policy_traits.h:163:54: error: ‘(absl::debian7::container_internal::TypeErasedApplyToSlotFn<absl::debian7::hash_internal::Hash<s2shapeutil::ShapeEdgeId>, s2shapeutil::ShapeEdgeId> == 0)’ is not a constant expression
163 | return Policy::template get_hash_slot_fn<Hash>() == nullptr
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
make[1]: *** [/home/hornik/tmp/R-d-gcc-xtra/etc/Makeconf:209: s2-cell-union.o] Error 1
make[1]: Leaving directory '/home/hornik/tmp/scratch/Rtmp64aE8U/R.INSTALL39cf7f43b390b1/s2/src'
ERROR: compilation failed for package ‘s2’
* removing ‘/home/hornik/tmp/CRAN_special_gcc-san/Library/s2’
Warning in (function (pkgs, lib, repos = getOption("repos"), contriburl = contrib.url(repos, :
installation of 11 packages failed:
‘s2’, ‘sf’, ‘lwgeom’, ‘stars’, ‘maptiles’, ‘tmaptools’, ‘leafpop’, ‘leafem’, ‘leafgl’, ‘mapview’, ‘tmap’
Calls: <Anonymous> -> do.call -> <Anonymous>
Full stack trace for sanitizer segfault:
* using log directory ‘/data/gannet/ripley/R/packages/tests-gcc-SAN/s2.Rcheck’
* using R Under development (unstable) (2025-05-11 r88197)
* using platform: x86_64-pc-linux-gnu
* R was compiled by
gcc-15 (GCC) 15.1.0
GNU Fortran (GCC) 15.1.0
* running under: Fedora Linux 40 (Workstation Edition)
...
> # returns the closest point on x to y
> s2_closest_point(
+ "POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))",
+ "POINT (0 90)" # north pole!
+ )
/usr/include/absl/container/internal/raw_hash_set.h:891:47: runtime error: load of null pointer of type 'GenerationType'
#0 0x7f846d91f403 in absl::lts_20240116::container_internal::CommonFieldsGenerationInfoEnabled::generation() const /usr/include/absl/container/internal/raw_hash_set.h:891
#1 0x7f846d91f403 in bool absl::lts_20240116::container_internal::HashSetResizeHelper::InitializeSlots<std::allocator<char>, 8ul, true, 4ul>(absl::lts_20240116::container_internal::CommonFields&, void*, std::allocator<char>) /usr/include/absl/container/internal/raw_hash_set.h:1622
#2 0x7f846d92d000 in absl::lts_20240116::container_internal::raw_hash_set<absl::lts_20240116::container_internal::FlatHashSetPolicy<s2shapeutil::ShapeEdgeId>, absl::lts_20240116::hash_internal::Hash<s2shapeutil::ShapeEdgeId>, std::equal_to<s2shapeutil::ShapeEdgeId>, std::allocator<s2shapeutil::ShapeEdgeId> >::resize(unsigned long) /usr/include/absl/container/internal/raw_hash_set.h:2929
#3 0x7f846d92ed0b in absl::lts_20240116::container_internal::raw_hash_set<absl::lts_20240116::container_internal::FlatHashSetPolicy<s2shapeutil::ShapeEdgeId>, absl::lts_20240116::hash_internal::Hash<s2shapeutil::ShapeEdgeId>, std::equal_to<s2shapeutil::ShapeEdgeId>, std::allocator<s2shapeutil::ShapeEdgeId> >::raw_hash_set(unsigned long, absl::lts_20240116::hash_internal::Hash<s2shapeutil::ShapeEdgeId> const&, std::equal_to<s2shapeutil::ShapeEdgeId> const&, std::allocator<s2shapeutil::ShapeEdgeId> const&) [clone .constprop.0] /usr/include/absl/container/internal/raw_hash_set.h:2104
#4 0x7f846d92f737 in absl::lts_20240116::flat_hash_set<s2shapeutil::ShapeEdgeId, absl::lts_20240116::hash_internal::Hash<s2shapeutil::ShapeEdgeId>, std::equal_to<s2shapeutil::ShapeEdgeId>, std::allocator<s2shapeutil::ShapeEdgeId> >::raw_hash_set(unsigned long, absl::lts_20240116::hash_internal::Hash<s2shapeutil::ShapeEdgeId> const&, std::equal_to<s2shapeutil::ShapeEdgeId> const&, std::allocator<s2shapeutil::ShapeEdgeId> const&) /usr/include/absl/container/flat_hash_set.h:152
#5 0x7f846d92f737 in S2ClosestEdgeQueryBase<S2MinDistance>::S2ClosestEdgeQueryBase() ../src/s2/s2closest_edge_query_base.h:481
#6 0x7f846d90d473 in S2ClosestEdgeQuery::S2ClosestEdgeQuery(S2ShapeIndex const*, S2ClosestEdgeQuery::Options const&) s2/s2closest_edge_query.h:376
#7 0x7f846da82218 in s2geography::s2_minimum_clearance_line_between(s2geography::ShapeIndexGeography const&, s2geography::ShapeIndexGeography const&) s2geography/distance.cc:40
#8 0x7f846da83715 in s2geography::s2_closest_point(s2geography::ShapeIndexGeography const&, s2geography::ShapeIndexGeography const&) s2geography/distance.cc:35
#9 0x7f846d9436de in processFeature /data/gannet/ripley/R/packages/tests-gcc-SAN/s2/src/s2-transformers.cpp:160
#10 0x7f846d94c616 in BinaryGeographyOperator<Rcpp::Vector<19, Rcpp::PreserveStorage>, SEXPREC*>::processVector(Rcpp::Vector<19, Rcpp::PreserveStorage>, Rcpp::Vector<19, Rcpp::PreserveStorage>) /data/gannet/ripley/R/packages/tests-gcc-SAN/s2/src/geography-operator.h:85
#11 0x7f846d94d0c1 in cpp_s2_closest_point(Rcpp::Vector<19, Rcpp::PreserveStorage>, Rcpp::Vector<19, Rcpp::PreserveStorage>) /data/gannet/ripley/R/packages/tests-gcc-SAN/s2/src/s2-transformers.cpp:170
#12 0x7f846d96bbf5 in _s2_cpp_s2_closest_point /data/gannet/ripley/R/packages/tests-gcc-SAN/s2/src/RcppExports.cpp:1224
After https://github.com/r-spatial/s2/pull/275 we'll only have the sanitizer crash to deal with 😮💨
Ok! I can reproduce with:
# R -e 'devtools::build()'
# cd ..
# mkdir check && cp s2_* check
# docker run --rm -it -v `pwd`/check:/check ghcr.io/r-hub/containers/gcc-asan:latest bash
dnf install openssl-devel abseil-cpp-devel
R -e 'pak::pak(c("wk", "Rcpp", "testthat", "vctrs", "bit64"))'
r-check
Or
# docker run --rm -it -v `pwd`:/s2 ghcr.io/r-hub/containers/gcc-asan:latest bash
dnf install openssl-devel abseil-cpp-devel
R -e 'pak::pak(c("wk", "Rcpp", "testthat", "vctrs", "bit64"))'
mkdir ~/.R && echo "MAKEFLAGS=-j24" >> ~/.R/Makevars
R CMD INSTALL . --preclean
R -e 's2::s2_closest_point("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))", "POINT (0 90)")'
The CXX flags are:
R CMD config CXX17
# g++ -fsanitize=address,undefined,bounds-strict -fno-omit-frame-pointer
...but I wasn't able to reproduce locally on Ubuntu 22.04:
echo 'CXX17=g++ -fsanitize=address,undefined,bounds-strict -fno-omit-frame-pointer' >> ~/.R/Makevars
R CMD INSTALL . --preclean
# ASan runtime does not come first in initial library list; you should either link runtime to your application or manually preload it with LD_PRELOAD.
Callsites in the backtrace:
https://github.com/abseil/abseil-cpp/blob/20240116.3/absl/container/internal/raw_hash_set.h#L891
https://github.com/abseil/abseil-cpp/blob/20240116.3/absl/container/internal/raw_hash_set.h#L1622
https://github.com/abseil/abseil-cpp/blob/20240116.3/absl/container/internal/raw_hash_set.h#L2929
https://github.com/abseil/abseil-cpp/blob/20240116.3/absl/container/internal/raw_hash_set.h#L2104
template <class Distance>
S2ClosestEdgeQueryBase<Distance>::S2ClosestEdgeQueryBase()
: tested_edges_(/*bucket_count=*/1) {}
Shall I try a new submission to CRAN? It seems the gcc-ubsan warning now has gone from here, the one on ISO C++ forbids zero-size array has been addressed, right? The macos warnings should be gone once abseil-cpp is part of Simon's recipes.
I believe everything else has been fixed, so go for it! We can also remove that example as a short-term fix if it's still there when we update.
Done!
... and on CRAN!