Comments (7)
It seems that inactivePairs_
somehow contains an invalid pointer. Perhaps related to splice iterators: https://stackoverflow.com/questions/143156/splice-on-stdlist-and-iterator-invalidation/143165#143165
Edit: we got a cycle in inactivePairs_
.
index d0affe3..c266358 100644
--- a/src/polygon/src/polygon.cpp
+++ b/src/polygon/src/polygon.cpp
@@ -88,10 +88,16 @@ class Monotones {
if (precision_ < 0) precision_ = bound * kTolerance;
- if (SweepForward()) return;
+ if (SweepForward()) {
+ std::cout << "sweepforward return" << std::endl;
+ return;
+ }
Check();
- if (SweepBack()) return;
+ if (SweepBack()) {
+ std::cout << "sweepback return" << std::endl;
+ return;
+ }
Check();
}
@@ -141,6 +147,27 @@ class Monotones {
// A variety of sanity checks on the data structure. Expensive checks are only
// performed if params.intermediateChecks = true.
void Check() {
+ std::vector<PairItr> pairs;
+ for (PairItr pair = activePairs_.begin(); pair != activePairs_.end(); pair++) {
+ if (std::find(pairs.begin(), pairs.end(), pair) != pairs.end()) {
+ std::cerr << "cycle" << std::endl;
+ abort();
+ }
+ pairs.push_back(pair);
+ }
+ unsigned int num = pairs.size();
+ for (PairItr pair = inactivePairs_.begin(); pair != inactivePairs_.end(); pair++) {
+ auto iter = std::find(pairs.begin(), pairs.end(), pair);
+ if (iter != pairs.end()) {
+ if (std::distance(pairs.begin(), iter) >= num)
+ std::cerr << "inactivePairs_ cycle" << std::endl;
+ else
+ std::cerr << "duplicate" << std::endl;
+ abort();
+ }
+ pairs.push_back(pair);
+ }
+
if (!params.intermediateChecks) return;
std::vector<Halfedge> edges;
for (VertItr vert = monotones_.begin(); vert != monotones_.end(); vert++) {
@@ -914,7 +941,9 @@ std::vector<glm::ivec3> Triangulate(const Polygons &polys, float precision) {
std::vector<glm::ivec3> triangles;
try {
Monotones monotones(polys, precision);
+ monotones.Check();
monotones.Triangulate(triangles);
+ monotones.Check();
if (params.intermediateChecks) {
CheckTopology(triangles, polys);
CheckGeometry(triangles, polys, precision);
It seems that the cycle is formed after failed sweep back (return non-zero in sweep back).
from manifold.
Thanks for the analysis! I should be able to use that to spit out a test case polygon. Good sleuthing!
from manifold.
I got address sanitizer working, but your patch isn't printing anything for me. Is there anything else required to repro? Also, if you replace abort()
with ALWAYS_ASSERT
, then the triangulator will catch the exception and print the problem polygon, which is what we need to make a minimal test case.
from manifold.
Did you change the max iteration to 10? The current one in master will not trigger the error.
from manifold.
Indeed I did; it fails, but on the munmap_chunk(): invalid pointer
or double free or corruption (out)
before any of your print statements hit.
from manifold.
Weird, or maybe the cycle is formed due to memory corruption and compiling this with different options somehow changed the behavior? No idea.
from manifold.
Okay, I managed to dump out the polygon and create a simple repro test.
from manifold.
Related Issues (20)
- Python created object reports as non-manifold. HOT 3
- Watertightness of Mesh with an Edge Shared by 4 Faces
- vertex halfedge iterator
- Manifold 2.4.5 release tar.gz is incomplete HOT 3
- Vec out of Range HOT 8
- Python binding needs two import call HOT 4
- Manifold Decompose doesn't preserve vertex properties HOT 4
- memory leak when TBB and PSTL is enabled HOT 27
- Triangulate bug: Two separate polygons HOT 5
- [Question] robust geometric predicates, polygon triangulation
- Warning comparison of integer expressions of different signedness
- Modularize Manifold HOT 25
- Build without exceptions HOT 3
- Remove Thrust HOT 19
- How to figure out required size of mem in the C-API? HOT 1
- Crash in Project() HOT 4
- gcc14 build failure HOT 7
- Triangulation issue: Zebra HOT 3
- BSD compiler error HOT 1
- Another Zebra Triangulation issue HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from manifold.