Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unstable behaviour when plotting very small cells #241

Open
paleolimbot opened this issue Jun 13, 2023 · 1 comment
Open

Unstable behaviour when plotting very small cells #241

paleolimbot opened this issue Jun 13, 2023 · 1 comment

Comments

@paleolimbot
Copy link
Collaborator

As reported by @mdsumner! I think he reported a crash...this just gives me a snap error. It is probably worth putting a limit on the level of simplification...I think this ends up boiling down to a radius of some kind and there's almost certainly a minimum useful value for that.

library(s2)

x <- s2_cell_polygon(s2_cell_parent(as_s2_cell(wk::xy(-67, 45)), 21))
plot(x, simplify = FALSE)

plot(x)
#> Error in eval(expr, envir, enclos): Snap function moved vertex (0.276288378258184, -0.650895382326694, 0.707106734026236) by 1.00136956986004e-09, which is more than the specified snap radius of 8.90734402968868e-10

Created on 2023-06-12 with reprex v2.0.2

@edzer
Copy link
Member

edzer commented Jun 13, 2023

Indeed, I get a valgrind stacktrace:

plot(x)
==210380== Invalid read of size 4
==210380==    at 0x4BAEBF47: S2Builder::MaybeAddExtraSites(int, int, std::vector<int, std::allocator<int> > const&, MutableS2ShapeIndex const&, std::vector<int, std::allocator<int> >*) (s2builder.cc:804)
==210380==    by 0x4BAEC347: S2Builder::AddExtraSites(MutableS2ShapeIndex const&) (s2builder.cc:788)
==210380==    by 0x4BAED17A: S2Builder::ChooseSites() (s2builder.cc:512)
==210380==    by 0x4BAED29E: S2Builder::Build(S2Error*) (s2builder.cc:474)
==210380==    by 0x4BAD2EA7: S2BooleanOperation::Impl::Build(S2Error*) (s2boolean_operation.cc:2260)
==210380==    by 0x4BAD2FC7: S2BooleanOperation::Build(S2ShapeIndex const&, S2ShapeIndex const&, S2Error*) (s2boolean_operation.cc:2380)
==210380==    by 0x4BAB1FE9: s2geography::s2_boolean_operation(s2geography::ShapeIndexGeography const&, s2geography::ShapeIndexGeography const&, S2BooleanOperation::OpType, s2geography::GlobalOptions const&) (build.cc:121)
==210380==    by 0x4BA8978A: BooleanOperationOp::processFeature(Rcpp::XPtr<RGeography, Rcpp::PreserveStorage, &(void Rcpp::standard_delete_finalizer<RGeography>(RGeography*)), false>, Rcpp::XPtr<RGeography, Rcpp::PreserveStorage, &(void Rcpp::standard_delete_finalizer<RGeography>(RGeography*)), false>, long) (s2-transformers.cpp:24)
==210380==    by 0x4BA88067: BinaryGeographyOperator<Rcpp::Vector<19, Rcpp::PreserveStorage>, SEXPREC*>::processVector(Rcpp::Vector<19, Rcpp::PreserveStorage>, Rcpp::Vector<19, Rcpp::PreserveStorage>) (geography-operator.h:85)
==210380==    by 0x4BA85052: cpp_s2_intersection(Rcpp::Vector<19, Rcpp::PreserveStorage>, Rcpp::Vector<19, Rcpp::PreserveStorage>, Rcpp::Vector<19, Rcpp::PreserveStorage>) (s2-transformers.cpp:37)
==210380==    by 0x4BA8C1BB: _s2_cpp_s2_intersection (RcppExports.cpp:1122)
==210380==    by 0x495629D: ??? (in /usr/lib/R/lib/libR.so)
==210380==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==210380== 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants