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

Eigen assert errors (Clang + Visual Studio 2019) #4

Open
ShnitzelKiller opened this issue Sep 1, 2020 · 4 comments
Open

Eigen assert errors (Clang + Visual Studio 2019) #4

ShnitzelKiller opened this issue Sep 1, 2020 · 4 comments

Comments

@ShnitzelKiller
Copy link

ShnitzelKiller commented Sep 1, 2020

For a single simple test example, (data/binary_input/apple-32/input.png), polyfit will sometimes manage to run and produce the desired output, but most of the time it will crash due to an eigen assert in the triangular solver.

Assertion failed: (it && it.index()==i), function run, file .../polyfit/dependencies/eigen/Eigen/src/SparseCore/TriangularSolver.h, line 84.

According to my debug trace, this happens due to CurveSequenceFitter::solve(), called from MultiPolygonTracer::trace(). Is this software not yet stable, or am I doing something wrong (my platform is OS X)?

@dedoardo
Copy link
Owner

dedoardo commented Sep 1, 2020

Hi, thank you for trying out the software on OS X and creating the respective pull request for clang :)

The software was developed on Windows using the Visual Studio 2017 compiler and I did not have a chance to test it on other platforms. All the inputs/outputs in the directory run fine under these conditions, but I encounter similar issues with the 2019 compiler, which is probably related to the one you are facing with Clang. I am very sorry about this.

Support for different platform is something worth addressing. To do so the most effective way is probably to (1) set up a unit test, (2) turn on more compiler warnings (3) debug and repeat.
Similarly, I am making it more clear in the README that this is an issue.

I am keeping this issue opened as reference (editing the title) and will merge your pull request when I get to do the above, which won't be in the immediate future, but will try to give it a shot in the next weeks.

curves_closed_screen

@dedoardo dedoardo changed the title Eigen assert errors Eigen assert errors (Clang + Visual Studio 2019) Sep 1, 2020
@ShnitzelKiller
Copy link
Author

ShnitzelKiller commented Sep 1, 2020

I did find what I'm pretty sure was a bug (added to my pull request #2 ) relating to bitwise operator precedence. Alas, it still crashes unpredictably. For the two times I have managed to produce output, the results differ:
apple1
apple2
Should results be non-deterministic to this degree?

@dedoardo
Copy link
Owner

dedoardo commented Sep 2, 2020

It's not lack of determinism in the algorithm, there is a bug in the code preventing the curve optimization stage to run. I obtain the same result by commenting out multi_polygon.cpp:256 (_solve_curves()). If you look closely, the per-corner primitive classification are the same between the two results, but the curves in the bottom row correspond to the initial guess.

As you pointed out in the first issue, the crashes you were obtaining were exactly in the CurveSequenceFitter::solve(), where the global optimization happens, hence the correlation between the two events.

I presume you managed to obtain the results by running it multiple times on the code compiled on Clang/OS X. As discussed above this is problem needs to be further investigated. I did not test the code on multiple platforms (no doubt I should have done that) and it's unfortunate that it's not showing up in VS2017. I will do my best to investigate it soon, after I've set up a simple test to make sure that outputs remain unchanged between commits.

example

@ShnitzelKiller
Copy link
Author

According to my research on the subject, the particular eigen assert error I get can be caused by a non-triangular sparse matrix being passed to the sparse triangular solver.

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