Closed flippmoke closed 9 years ago
TODO:
Above commits will ensure this exception is handled and does not abort.
How coordinates are getting through - that are outside the valid range of clipper - is still a mystery. All we know is that this occurred at z15
. We don't know what kind of geometry triggered this.
One thought was that doubles were overflowing here however that is very unlikely the case. Clipper's hirange
value of 0x3FFFFFFFFFFFFFFFLL
or 4611686018427387903
is half the size of std::numeric_limits<std::int64_t>::max()
. So we don't need an int64
overflow to trigger a value greater than hirange
and an exception in ClipperLib::RangeTest
.
Based on 1fba0d2 it does not look feasible for vector_tile_strategy
alone to produce values greater than hirange
at z15
even for a geometry that spans the world.
The only way I could trigger values beyond hirange
was with an unrealistic scaling
factor that is absurdly big (1000000000000.0
). Even though that test is unrealistic I left it in - if it ever changes behavior we'll want to know.
So, I think the best way forward is to try to isolate a geometry next time this happens /cc @MateoV. For now I'll close this ticket but will re-open if we find a way to replicate.
For future debugging:
diff --git a/src/vector_tile_strategy.hpp b/src/vector_tile_strategy.hpp
index 1f8c045..fd9d030 100644
--- a/src/vector_tile_strategy.hpp
+++ b/src/vector_tile_strategy.hpp
@@ -64,6 +64,16 @@ struct vector_tile_strategy
y = y * scaling_;
x = std::round(x);
y = std::round(y);
+#if defined(DEBUG)
+ if (x >= 0x3FFFFFFFFFFFFFFFLL || x <= -0x3FFFFFFFFFFFFFFFLL)
+ {
+ std::clog << std::fixed << " x out of bounds: " << x << "\n";
+ }
+ if (y >= 0x3FFFFFFFFFFFFFFFLL || y <= -0x3FFFFFFFFFFFFFFFLL)
+ {
+ std::clog << std::fixed << " y out of bounds: " << y << "\n";
+ }
+#endif
boost::geometry::set<0>(p2, static_cast<p2_type>(x));
boost::geometry::set<1>(p2, static_cast<p2_type>(y));
return true;
How coordinates are getting through - that are outside the valid range of clipper - is still a mystery.
Mystery solved: pj_transform
may set x/y to HUGE_VAL
while returning no error. This triggers this bug: https://github.com/mapbox/mapnik-vector-tile/issues/116#issuecomment-110964474
How coordinates are getting through - that are outside the valid range of clipper - is still a mystery.
Mystery solved: pj_transform may set x/y to HUGE_VAL while returning no error. This triggers this bug: #116 (comment)
Now with the help of @MateoV - we've isolated a testcase for another way this can happen. Which is an extremely invalid coordinate which cannot fit within a 64 bit integer after being scaled to integer space. Will track at #120
Revealed a coredump that was uncaught in AddPath. More then likely it is due to:
Either https://github.com/mapnik/mapnik/blob/master/deps/clipper/src/clipper.cpp#L889 or https://github.com/mapnik/mapnik/blob/master/deps/clipper/src/clipper.cpp#L1040 or https://github.com/mapnik/mapnik/blob/master/deps/clipper/src/clipper.cpp#L1069 as the callstack doesn't show it getting any deeper.