r-spatial / r-spatial/s2

new CRAN issues w. absl

Open
#293 31 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
81
Forks
19
Avg merge
20h 25m
Merged PRs (30d)
3

Description

We got this message some weeks ago:

A recent CRAN submission (FORTLS) failed in my gcc-san checks because
pacakge s2 failed to install.  Specifically, for my enhanced gcc build
the installation error is

g++-15 -fsanitize=address,undefined,bounds-strict -fno-omit-frame-pointer -std=g
nu++17 -I"/home/hornik/tmp/R-d-gcc-xtra/include" -DNDEBUG -I../src -DSTRICT_R_HE
ADERS -I'/home/hornik/tmp/CRAN_special_gcc-san/Library/Rcpp/include' -I'/home/ho
rnik/tmp/CRAN_special_gcc-san/Library/wk/include' -I/usr/local/include -DUSE_TYP
E_CHECKING_STRICT -D_FORTIFY_SOURCE=3  -pthread -fpic  -g -O2 -Wall -pedantic -m
tune=native  -Wno-ignored-attributes -Wno-deprecated-declarations -Wno-stringop-
truncation   -c s2-cell-union.cpp -o s2-cell-union.o

...

/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>](s2shapeutil::ShapeEdgeId), void>::get_hash_slot_fn<absl::debian7::hash_internal::Hash[<s2shapeutil::ShapeEdgeId>](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), s2shapeutil::ShapeEdgeId> == 0)’ is not a constant expression
  163 |     return policy::template get_hash_slot_fn<Hash>() == nullptr
      |            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~

For my enhanced clang build I can installed but at runtime get

> # binary operations: difference, symmetric difference, intersection and union
> s2_difference(
+   "POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))",
+   "POLYGON ((5 5, 15 5, 15 15, 5 15, 5 5))",
+   # 32 bit platforms may need to set snap rounding
+   s2_options(snap = s2_snap_level(30))
+ )
/usr/include/absl/container/internal/raw_hash_set.h:991:46: runtime error: load 
of null pointer of type 'GenerationType' (aka 'unsigned char')
    #0 0x7bf2b780e5d1 in absl::debian7::container_internal::CommonFieldsGenerati
oninfoenabled::generation() const /usr/include/absl/container/internal/raw_hash_
set.h:991:46
    #1 0x7bf2b780e5d1 in bool absl::debian7::container_internal::HashSetResizeHe
lper::InitializeSlots<std::allocator<char>, 4ul, true, true, 4ul>(absl::debian7:
:container_internal::CommonFields&, std::allocator<char>, absl::debian7::contain
er_internal::ctrl_t, unsigned long, unsigned long) /usr/include/absl/container/i
nternal/raw_hash_set.h:2070:45
    #2 0x7bf2b780dc18 in absl::debian7::container_internal::raw_hash_set<absl::d
ebian7::container_internal::FlatHashSetPolicy<int>, absl::debian7::hash_internal
::Hash<int>, std::equal_to<int>, std::allocator<int>>::resize_impl(absl::debian7
::container_internal::CommonFields&, unsigned long, absl::debian7::container_int
ernal::HashtablezInfoHandle) /usr/include/absl/container/internal/raw_hash_set.h
:3662:23
    #3 0x7bf2b77e0845 in absl::debian7::flat_hash_set<int, absl::debian7::hash_i
nternal::Hash<int>, std::equal_to<int>, std::allocator<int>>::flat_hash_set(unsi
gned long, absl::debian7::hash_internal::Hash<int> const&, std::equal_to<int> co
nst&, std::allocator<int> const&) /usr/include/absl/container/flat_hash_set.h:172:15
    #4 0x7bf2b77e0845 in s2builder::AddExtraSites(MutableS2ShapeIndex const&) /h
ome/hornik/tmp/CRAN/s2.Rcheck/00_pkg_src/s2/src/s2/s2builder.cc:901:30

etc.

I also tried the effect of getting a newer libabls-dev from
experimental: this now has both gcc-san and clang-san fail to install.

It looks like the absl version (system, 20240722) is too new for the s2geometry version we bundle. A solution would be to use the vendored (bundled) absl, but by default we pick up a system absl if it is new enough (>= 20230802); absl however does not aim for backward compatability and s2geometry wants particular versions of it, not >= some version. I've tried to replace s2geometry with 0.12.0 bundled with absl 20240116 but get a missing symbol error when linking s2.so (some absl module missing); I had to uncommend (remove) this line

https://github.com/r-spatial/s2/blob/ad09e15f8f37a244dd4b108b094d476fe871ca0f/src/init.cpp#L23

to get that running; I also tried s2geometry 0.13.1` with the absl it requires (20250814) but that led to other problems, e.g. here

https://github.com/r-spatial/s2/blob/ad09e15f8f37a244dd4b108b094d476fe871ca0f/src/s2geography/constructor.h#L246

where changing text() into message() didn't resolve the problem.

Two issues where I'm hanging now (WIP!):

  • how does "our" absl_s2.pc lead to the long list of absl modules to link? (this needs to be fixed, somehow, to include all needed modules when upgrading s2geometry and bundled absl)
  • should we go back from using the system absl by default, given that s2geometry essentially pins a version, and always use the bundled/vendored version?

@paleolimbot

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the bundled absl_s2.pc and src/init.cpp around line 23 to trace which Abseil modules are linked, then inspect src/s2geography/constructor.h around line 246. Compare the bundled and system Abseil paths with the s2geometry versions described in the issue. Done means choosing a supported Abseil strategy, linking every required module, and avoiding the reported GCC and Clang sanitizer failures.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
build-system
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.