8000 Minimal s2 update to fix sanitizer issue (#17946) · cloudhub-js/arangodb@ee30284 · GitHub
[go: up one dir, main page]

Skip to content

Commit ee30284

Browse files
authored
Minimal s2 update to fix sanitizer issue (arangodb#17946)
1 parent 7c5a206 commit ee30284

File tree

9 files changed

+38
-13
lines changed

9 files changed

+38
-13
lines changed

3rdParty/s2geometry/master/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ if (WITH_GFLAGS)
6868
add_definitions(-DS2_USE_GFLAGS)
6969
endif()
7070

71+
# If we already have abseil we don't need to find it, for an example:
72+
# add_subdirectory(absl-submbodule)
73+
# add_subdirectory(s2-submodule)
74+
if (NOT TARGET absl::base)
75+
find_package(absl REQUIRED)
76+
endif()
7177
find_package(OpenSSL REQUIRED)
7278
# pthreads isn't used directly, but this is still required for std::thread.
7379
find_package(Threads REQUIRED)
@@ -254,7 +260,7 @@ endif()
254260
# list(APPEND CMAKE_MODULE_PATH "<path_to_s2geometry_dir>/third_party/cmake")
255261
# add_subdirectory(<path_to_s2geometry_dir> s2geometry)
256262
# target_link_libraries(<target_name> s2)
257-
target_include_directories(s2 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src)
263+
target_include_directories(s2 SYSTEM PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src)
258264

259265
# Add version information to the target
260266
set_target_properties(s2 PROPERTIES

3rdParty/s2geometry/master/src/python/pywraps2_test.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,14 @@ def testS2UpdateMinDistance(self):
826826
self.assertFalse(s2.UpdateMinDistance(pC, p1, p2, md))
827827
self.assertAlmostEqual(0.1478883, md.degrees())
828828

829+
def testS1AngleToString(self):
830+
a = s2.S1Angle.Degrees(123)
831+
self.assertEqual("123.0000000", str(a))
832+
833+
def testS2CellIdToString(self):
834+
a = s2.S2CellId(12345)
835+
self.assertEqual("0/000000000000000000000001200130", str(a))
836+
829837
class RegionTermIndexerTest(unittest.TestCase):
830838
def _randomCaps(self, query_type, **indexer_options):
831839
# This function creates an index consisting either of points (if

3rdParty/s2geometry/master/src/python/s2_common.i

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,7 @@ public:
922922
%extend type {
923923
std::string __str__() {
924924
std::ostringstream output;
925-
output << *$self << std::ends;
925+
output << *$self;
926926
return output.str();
927927
}
928928
}

3rdParty/s2geometry/master/src/s2/encoded_s2point_vector.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -464,9 +464,6 @@ void EncodeS2PointVectorCompact(Span<const S2Point> points, Encoder* encoder) {
464464
// Now we encode the contents of each block.
465465
StringVectorEncoder blocks;
466466
vector<S2Point> exceptions;
467-
uint64 offset_bytes_sum = 0;
468-
uint64 delta_nibbles_sum = 0;
469-
uint64 exceptions_sum = 0;
470467
for (int i = 0; i < values.size(); i += kBlockSize) {
471468
int block_size = min(kBlockSize, values.size() - i);
472469
BlockCode code = GetBlockCode(MakeSpan(&values[i], block_size),
@@ -536,9 +533,6 @@ void EncodeS2PointVectorCompact(Span<const S2Point> points, Encoder* encoder) {
536533
block->Ensure(exceptions_bytes);
537534
block->putn(exceptions.data(), exceptions_bytes);
538535
}
539-
offset_bytes_sum += offset_bytes;
540-
delta_nibbles_sum += delta_nibbles;
541-
exceptions_sum += num_exceptions;
542536
}
543537
blocks.Encode(encoder);
544538
}

3rdParty/s2geometry/master/src/s2/s2loop.cc

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,14 @@ S2Loop::S2Loop(S2Loop&& b)
110110
b.unindexed_contains_calls_.exchange(0, std::memory_order_relaxed)),
111111
bound_(std::move(b.bound_)),
112112
subregion_bound_(std::move(b.subregion_bound_)),
113-
index_(std::move(b.index_)) {}
113+
index_(std::move(b.index_)) {
114+
// `index_` has a pointer to an S2Loop::Shape which points to S2Loop.
115+
// But, we've moved to a new address, so get the Shape back out of the index
116+
// and update it to point to our new location.
117+
if (index_.begin() != index_.end()) {
118+
down_cast<Shape*>(*index_.begin())->loop_ = this;
119+
}
120+
}
114121

115122
S2Loop& S2Loop::operator=(S2Loop&& b) {
116123
if (owns_vertices_) {
@@ -131,6 +138,13 @@ S2Loop& S2Loop::operator=(S2Loop&& b) {
131138
subregion_bound_ = std::move(b.subregion_bound_);
132139
index_ = std::move(b.index_);
133140

141+
// `index_` has a pointer to an S2Loop::Shape which points to S2Loop.
142+
// But, we've moved to a new address, so get the Shape back out of the index
143+
// and update it to point to our new location.
144+
if (index_.begin() != index_.end()) {
145+
down_cast<Shape*>(*index_.begin())->loop_ = this;
146+
}
147+
134148
return *this;
135149
}
136150
#endif

3rdParty/s2geometry/master/src/s2/s2loop.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,9 @@ class S2Loop final : public S2Region {
470470
// details).
471471
#ifndef SWIG
472472
class Shape : public S2Shape {
473+
// To update `loop_` in `S2Loop` move constructor/assignment.
474+
friend class S2Loop;
475+
473476
public:
474477
Shape() : loop_(nullptr) {} // Must call Init().
475478

3rdParty/s2geometry/master/src/s2/s2polygon.cc

Lines changed: 1 addition & 1 deletion
< 1060D /tr>
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
#include <array>
2222
#include <cmath>
2323
#include <cstddef>
24-
#include <memory>
2524
#include <map>
25+
#include <memory>
2626
#include <stack>
2727
#include <utility>
2828
#include <vector>

3rdParty/s2geometry/master/src/s2/util/gtl/compact_array.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,8 +415,8 @@ class compact_array_base {
415415
T* new_ptr = allocator.allocate(capacity());
416416
if (old_capacity != 0) {
417417
memcpy(new_ptr, Array(), old_capacity * sizeof(T));
418+
allocator.deallocate(Array(), old_capacity);
418419
}
419-
allocator.deallocate(Array(), old_capacity);
420420

421421
SetArray(new_ptr);
422422
}

LICENSES-OTHER-COMPONENTS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,8 +464,8 @@ _Enterprise Edition only_
464464
### S2 Geometry Library
465465

466466
* Name: s2geometry
467-
* Version: 254c13666f65f35f5343d34dfbc749e1fb7772ca
468-
* Date: 2022-11-18
467+
* Version: ce14f45ae0b6c28e3f47cbcf6646d988d41046b5
468+
* Date: 2023-01-04
469469
* Project Home: https://s2geometry.io/
470470
* License: https://raw.githubusercontent.com/arangodb/arangodb/devel/3rdParty/s2geometry/dfefe0c/LICENSE
471471
* License Name: Apache License 2.0

0 commit comments

Comments
 (0)
0