MIT-SPARK / TEASER-plusplus

A fast and robust point cloud registration library
MIT License
1.81k stars 343 forks source link

[BUG] Memory release errors during solving #129

Closed AndreiCostinescu closed 6 months ago

AndreiCostinescu commented 2 years ago

Describe the bug I get memory allocation errors from the solver.solve(x, y) function (munmap_chunk(): invalid pointer or double free or corruption (out) or free(): invalid size) when running a simple registration example (code and data attached, see To Reproduce section).

Have you run the unit tests? Test project /usr/local/src/TEASER-plusplus/build-release Start 1: UtilsTest.RandomSample 1/48 Test 1: UtilsTest.RandomSample ............................... Passed 0.00 sec Start 2: UtilsTest.EigenMatrixRemoveRowColumn 2/48 Test 2: UtilsTest.EigenMatrixRemoveRowColumn ................. Passed 0.00 sec Start 3: UtilsTest.CalculatePointClusterDiameter 3/48 Test 3: UtilsTest.CalculatePointClusterDiameter .............. Passed 0.00 sec Start 4: IOTest.ImportPLY 4/48 Test 4: IOTest.ImportPLY ..................................... Passed 0.00 sec Start 5: IOTest.ImportBigPLY 5/48 Test 5: IOTest.ImportBigPLY .................................. Passed 0.22 sec Start 6: PointXYZTest.SimpleOperations 6/48 Test 6: PointXYZTest.SimpleOperations ........................ Passed 0.00 sec Start 7: PointCloudTest.SimpleOperations 7/48 Test 7: PointCloudTest.SimpleOperations ...................... Passed 0.00 sec Start 8: TLSTest.TLSEstimate 8/48 Test 8: TLSTest.TLSEstimate .................................. Passed 0.00 sec Start 9: TLSTest.TLSEstimateTiled 9/48 Test 9: TLSTest.TLSEstimateTiled ............................. Passed 0.01 sec Start 10: ScaleSolverTest.UnknownScale 10/48 Test 10: ScaleSolverTest.UnknownScale ......................... Passed 0.00 sec Start 11: ScaleSolverTest.FixedScale 11/48 Test 11: ScaleSolverTest.FixedScale ........................... Passed 0.00 sec Start 12: RotationSolverTest.FGRRotation 12/48 Test 12: RotationSolverTest.FGRRotation ....................... Passed 0.00 sec Start 13: RotationSolverTest.GNCTLS 13/48 Test 13: RotationSolverTest.GNCTLS ............................ Passed 0.00 sec Start 14: TranslationTest.TLSTranslation 14/48 Test 14: TranslationTest.TLSTranslation ....................... Passed 0.00 sec Start 15: RegistrationTest.LargeModel 15/48 Test 15: RegistrationTest.LargeModel .......................... Passed 0.01 sec Start 16: RegistrationTest.SolveForScale 16/48 Test 16: RegistrationTest.SolveForScale ....................... Passed 0.01 sec Start 17: RegistrationTest.SolveForRotation 17/48 Test 17: RegistrationTest.SolveForRotation .................... Passed 0.00 sec Start 18: RegistrationTest.SolveRegistrationProblemDecoupled 18/48 Test 18: RegistrationTest.SolveRegistrationProblemDecoupled ...***Exception: SegFault 0.08 sec Start 19: RegistrationTest.OutlierDetection 19/48 Test 19: RegistrationTest.OutlierDetection .................... Passed 0.01 sec Start 20: RegistrationTest.NoMaxClique 20/48 Test 20: RegistrationTest.NoMaxClique ......................... Passed 0.00 sec Start 21: RegistrationTest.CliqueFinderModes 21/48 Test 21: RegistrationTest.CliqueFinderModes ................... Passed 0.00 sec Start 22: GraphTest.BasicFunctions 22/48 Test 22: GraphTest.BasicFunctions ............................. Passed 0.00 sec Start 23: PMCTest.FindMaximumClique1 23/48 Test 23: PMCTest.FindMaximumClique1 ........................... Passed 0.01 sec Start 24: PMCTest.FindMaximumClique2 24/48 Test 24: PMCTest.FindMaximumClique2 ........................... Passed 0.01 sec Start 25: PMCTest.FindMaximumClique3 25/48 Test 25: PMCTest.FindMaximumClique3 ........................... Passed 0.01 sec Start 26: MaxCliqueSolverTest.FindMaxClique 26/48 Test 26: MaxCliqueSolverTest.FindMaxClique .................... Passed 0.01 sec Start 27: DRSCertifierTest.GetOmega1 27/48 Test 27: DRSCertifierTest.GetOmega1 ........................... Passed 0.02 sec Start 28: DRSCertifierTest.GetBlockDiagOmega 28/48 Test 28: DRSCertifierTest.GetBlockDiagOmega ................... Passed 0.02 sec Start 29: DRSCertifierTest.GetQCost 29/48 Test 29: DRSCertifierTest.GetQCost ............................ Passed 0.02 sec Start 30: DRSCertifierTest.GetLambdaGuess 30/48 Test 30: DRSCertifierTest.GetLambdaGuess ...................... Passed 0.02 sec Start 31: DRSCertifierTest.GetLinearProjection 31/48 Test 31: DRSCertifierTest.GetLinearProjection ................. Passed 0.02 sec Start 32: DRSCertifierTest.GetOptimalDualProjection 32/48 Test 32: DRSCertifierTest.GetOptimalDualProjection ............ Passed 0.03 sec Start 33: DRSCertifierTest.ComputeSubOptimalityGap 33/48 Test 33: DRSCertifierTest.ComputeSubOptimalityGap ............. Passed 0.02 sec Start 34: DRSCertifierTest.Certify 34/48 Test 34: DRSCertifierTest.Certify ............................. Passed 0.14 sec Start 35: DRSCertifierTest.LargeInstance 35/48 Test 35: DRSCertifierTest.LargeInstance ....................... Passed 15.98 sec Start 36: DRSCertifierTest.Random100Points 36/48 Test 36: DRSCertifierTest.Random100Points ..................... Passed 0.54 sec Start 37: DRSCertifierTest.RandomLargeInstsances 37/48 Test 37: DRSCertifierTest.RandomLargeInstsances ............... Passed 9.59 sec Start 38: LinalgTest.HatMap 38/48 Test 38: LinalgTest.HatMap .................................... Passed 0.00 sec Start 39: LinalgTest.VectorKronFixedSize 39/48 Test 39: LinalgTest.VectorKronFixedSize ....................... Passed 0.01 sec Start 40: LinalgTest.VectorKronDynamicSize 40/48 Test 40: LinalgTest.VectorKronDynamicSize ..................... Passed 0.00 sec Start 41: LinalgTest.GetNearestPSDRandom 41/48 Test 41: LinalgTest.GetNearestPSDRandom ....................... Passed 0.13 sec Start 42: LinalgTest.GetNearestPSDSimple 42/48 Test 42: LinalgTest.GetNearestPSDSimple ....................... Passed 0.00 sec Start 43: RegistrationBenchmark.Benchmark1 43/48 Test 43: RegistrationBenchmark.Benchmark1 ..................... Passed 0.02 sec Start 44: RegistrationBenchmark.Benchmark2 44/48 Test 44: RegistrationBenchmark.Benchmark2 ..................... Passed 0.01 sec Start 45: RegistrationBenchmark.Benchmark3 45/48 Test 45: RegistrationBenchmark.Benchmark3 ..................... Passed 0.02 sec Start 46: RegistrationBenchmark.Benchmark4 46/48 Test 46: RegistrationBenchmark.Benchmark4 ..................... Passed 0.05 sec Start 47: RegistrationBenchmark.Benchmark5 47/48 Test 47: RegistrationBenchmark.Benchmark5 ..................... Passed 0.15 sec Start 48: RegistrationBenchmark.Benchmark6 48/48 Test 48: RegistrationBenchmark.Benchmark6 ..................... Passed 0.17 sec

98% tests passed, 1 tests failed out of 48

Total Test time (real) = 27.37 sec

The following tests FAILED: 18 - RegistrationTest.SolveRegistrationProblemDecoupled (SEGFAULT) Errors while running CTest

Have you read the documentation?

Installed Dependencies OS: Ubuntu 18.04.6 Eigen: 3.3.4 Teaserpp: master version (d79d0c678b973e052796bc75d3f77025363726d6); the errors also occur on version 2.0

To Reproduce Execute the attached code with the attached data file. May need multiple runs to get the errors... Also, you may need to change the path to the data file :innocent: Data file: points.txt Code file (change extension to .cpp): test.txt

Additional context Here are some outputs from my runs (the final one is the one that doesn't produce errors)

Starting scale solver. Scale estimation complete. Max core number: 21 Num vertices: 408 [pmc heuristic: thread 1] current max clique = 6, time = 1.5974e-05 sec [pmc heuristic: thread 3] current max clique = 8, time = 4.1008e-05 sec [pmc heuristic: thread 14] current max clique = 9, time = 5.6982e-05 sec [pmc heuristic: thread 8] current max clique = 10, time = 6.79493e-05 sec [pmc heuristic] mc = 10 Created adjacency matrix in 7.39098e-05 seconds [pmc: initial k-core pruning] before pruning: |V| = 407, |E| = 3445 [pmc: initial k-core pruning] after pruning: |V| = 296, |E| = 2793 [pmc] initial pruning took 2.69413e-05 sec [pmc: sorting neighbors] |E| = 5586, |E_sorted| = 5586 |V| = 270

[pmc: thread 14] [pmc: bounds updated - thread 13] time = 0.000217199 sec, |V| = 285 (122 / 407), |E| = 2793, w = 10, p = 0.033805, d_min = 1, d_avg = 16.9287, d_max = 33, k_max = 21 [pmc: bounds updated - thread 14] time = [pmc: bounds updated - thread 15] time = 0.00023818 sec, |V| = 292 (115 / 407), |E| = 2793, w = 10, p = 0.033805, d_min = 1, d_avg = 0.000240088 sec, |V| = 16.9287, d_max = 33, k_max = 177 (21230 / 407), |E| = 2793, w = 10, p = 0.033805, d_min = 1, d_avg = [pmc: bounds updated - thread 16.9287, d_max = 1633, k_max = ] 21time = 0.000260115 sec, |V| = 138 (269 / 407), |E| = 2793, w = 10, p = 0.033805, d_min = 1, d_avg = 16.9287, d_max = 33, k_max = 21

munmap_chunk(): invalid pointer

Starting scale solver. Scale estimation complete. Max core number: 21 Num vertices: 408 [pmc heuristic: thread 13] current max clique = 6, time = 1.5974e-05 sec [pmc heuristic: thread 10] current max clique = 8, time = 4.29153e-05 sec *** [pmc heuristic: thread 3] current max clique = 10, time = 5.6982e-05 sec [pmc heuristic] mc = 10 Created adjacency matrix in 7.31945e-05 seconds [pmc: initial k-core pruning] before pruning: |V| = 407, |E| = 3445 [pmc: initial k-core pruning] after pruning: |V| = 296, |E| = 2793 [pmc] initial pruning took 2.28882e-05 sec [pmc: sorting neighbors] |E| = 5586, |E_sorted| = 5586 |V| = 270

[pmc: thread 13] [pmc: bounds updated - thread 16] time = [pmc: bounds updated - thread 14] time = 0.000204086 sec, |V| = 294 (113 / 407), |E| = 2793, w = 10, p = 0.033805, d_min = 10.000205994, d_avg = sec, |V| = 285 (122 / 407), |E| = 2793, w = 10, p = 16.9287, d_max = 33, k_max = 210.033805, d_min = 1 , d_avg = 16.9287, d_max = 33, k_max = 21 [pmc: bounds updated - thread 15] time = [pmc: bounds updated - thread 13] time = 0.000234127 sec, |V| = 172 (235 / 0.000236034407), |E| = sec, 2793, w = |V| = 10, p = 295 (112 / 407), |E| = 2793, w = 10, p = 0.033805, d_min = 1, d_avg = 0.033805, d_min = 1, d_avg = 16.9287, d_max = 33, k_max = 21 16.9287, d_max = 33, k_max = 21

double free or corruption (out)

Starting scale solver. Scale estimation complete. Max core number: 21 Num vertices: 408 [pmc heuristic: thread 1] current max clique = 6, time = 1.5974e-05 sec [pmc heuristic: thread 2] current max clique = 8, time = 4.1008e-05 sec *** [pmc heuristic: thread 8] current max clique = 10, time = 5.50747e-05 sec [pmc heuristic] mc = 10 Created adjacency matrix in 7.60555e-05 seconds [pmc: initial k-core pruning] before pruning: |V| = 407, |E| = 3445 [pmc: initial k-core pruning] after pruning: |V| = 296, |E| = 2793 [pmc] initial pruning took 2.28882e-05 sec [pmc: sorting neighbors] |E| = 5586, |E_sorted| = 5586 |V| = 270

[pmc: thread 13[pmc: bounds updated - thread [pmc: bounds updated - thread [pmc: bounds updated - thread 14] 16time = ] time = 15] time = ] 0.000195026 sec, |V| = 285 (122 / 407), |E| = 2793, w = 10, p = 0.0001950260.033805, d_min = 1, d_avg = 16.9287, d_max = sec, 33|V| = 293, k_max = 21 ( 114 / 407), |E| = 2793, w = 10, p = [pmc: bounds updated - thread 13] time = 0.0001978870.033805 sec, , d_min = 1|V| = , d_avg = 294 (113 / 407), |E| = 2793, w = 10, p = 16.9287, d_max = 33, k_max = 21 0.033805, d_min = 1, d_avg = 0.00022792816.9287 sec, , d_max = |V| = 33295 (, k_max = 11221 / 407 ), |E| = 2793, w = 10, p = 0.033805, d_min = 1, d_avg = 16.9287, d_max = 33, k_max = 21

free(): invalid size

Starting scale solver. Scale estimation complete. Max core number: 21 Num vertices: 408 [pmc heuristic: thread 14] current max clique = 6, time = 1.50204e-05 sec [pmc heuristic: thread 9] current max clique = 8, time = 4.19617e-05 sec *** [pmc heuristic: thread 14] current max clique = 10, time = 5.6982e-05 sec [pmc heuristic] mc = 10 Created adjacency matrix in 7.29561e-05 seconds [pmc: initial k-core pruning] before pruning: |V| = 407, |E| = 3445 [pmc: initial k-core pruning] after pruning: |V| = 296, |E| = 2793 [pmc] initial pruning took 2.7895e-05 sec [pmc: sorting neighbors] |E| = 5586, |E_sorted| = 5586 |V| = 270

[pmc: thread 16] [pmc: bounds updated - thread 13] time = [pmc: bounds updated - thread 0.000206947 sec, |V| = 290 (117 / 407), |E| = 2793, w = 10, p = 0.03380514, d_min = ] time = 1, d_avg = 16.9287, d_max = 33, k_max = 21 0.000213861 sec, |V| = 286 (121 / 407), |E| = 2793, w = 10, p = 0.033805, d_min = 1, d_avg = 16.9287, d_max = 33, k_max = 21 [pmc: bounds updated - thread 16] time = 0.000232935 sec, |V| = 291 (116 / 407), |E| = 2793, w = 10, p = 0.033805, d_min = 1, d_avg = 16.9287, d_max = 33, k_max = 21 [pmc: bounds updated - thread 15] time = 0.00169587 sec, |V| = 274 (133 / 407), |E| = 2793, w = 10, p = 0.033805, d_min = 1, d_avg = 16.9287, d_max = 33, k_max = 21

Max Clique of scale estimation inliers: Using chain graph for GNC rotation. Starting rotation solver. GNC rotation estimation noise bound:0.02 GNC rotation estimation noise bound squared:0.0004 GNC-TLS solver terminated due to cost convergence. Cost diff: 0 Iterations: 14 Rotation estimation complete. Starting translation solver. Translation estimation complete. Found solution? 1 t = 103.638 -153.34 106.407 R = -1.54759e-05 -0.511897 -0.859047 -1 1.54759e-05 8.79329e-06 8.79329e-06 0.859047 -0.511897 s = 1

lidonghui-ai commented 2 years ago

Have you solved this bug yet? The same bug was encountered

AndreiCostinescu commented 2 years ago

No, this is still an active issue for me...

lidonghui-ai commented 2 years ago

No, this is still an active issue for me...

Hi,I have solve it by setting the environment variable OMP_NUM_THREADS=12. export OMP_NUM_THREADS=12

lidonghui-ai commented 2 years ago

see issue https://github.com/MIT-SPARK/TEASER-plusplus/issues/54#issuecomment-829305428 for details.

No, this is still an active issue for me...

Hi,I have solve it by setting the environment variable OMP_NUM_THREADS=12. export OMP_NUM_THREADS=12

jingnanshi commented 2 years ago

@AndreiCostinescu @lidonghui-ai In the latest commit to the develop branch I have fixed this issue. Now you should be able to run it without setting the environmental variable. Please let me know if you run into any more issues.

LimHyungTae commented 6 months ago

If there are no further questions, we will close the issue :) Thx