> So I just noticed that my nightly build of ITK 4 has been > failing ever since Debian switched to gcc 4.7 [1]. The > previous night was successful [2]. Might be worth switching > to gcc-4.6 for the build. > > > [1] http://open.cdash.org/buildSummary.php?buildid=2260572 > [2] http://open.cdash.org/buildSummary.php?buildid=2257925 > > -Steve
Attached is a patch that will fix the failed FEM tests. Let me know if there are any problems. The segfaults are still there though. BTW, the segfaults go away with -O2 instead of the default -O3 optimization. We'll see where that leads. -Paul
Description: Fix Failed FEM Tests on gcc 4.7 With any optimization (-O1, -O2, -O3), the following tests were failing . 557 - itkFEMC0HexahedralElement-NodalLoads-BCs (Failed) 559 - itkFEMC0HexahedralElement-GravityLoad-BCs (Failed) 560 - itkFEMC0TetrahedralElement-NodalLoads-BCs (Failed) 562 - itkFEMC0TetrahedralElement-GravityLoad-BCs (Failed) 563 - itkFEMC0QuadElement-NodalLoads-BCs (Failed) 564 - itkFEMC0QuadElement-Strain (Failed) 566 - itkFEMC0QuadElement-GravityLoad-BCs (Failed) 567 - itkFEMLoadLandmarkImplementation (Failed) 569 - itkFEMC0TriangularElement-NodalLoads-BCs (Failed) 572 - itkFEMC0TriangularElement-Quadratic (Failed) 573 - itkFEMTruss (Failed) . It looks like expectedSolution in the code below was pointing to some unitialized memory. So while the tests were giving the right result, the expectedSolution was wrong. This change just sets expectedSolution directly instead of pointing it to the first element in an array that is no longer on the stack. Author: Paul Novotny <p...@paulnovo.us> --- debian-svn.orig/Modules/Numerics/FEM/test/itkFEMElement2DTest.cxx +++ debian-svn/Modules/Numerics/FEM/test/itkFEMElement2DTest.cxx @@ -90,7 +90,8 @@ femSO->GetFEMObject()->FinalizeMesh(); - double * expectedSolution = NULL; + double expectedSolution[12]; + bool haveExpectedSolution = false; bool foundError = false; std::string modelFile = itksys::SystemTools::GetFilenameName( argv[1] ); @@ -137,135 +138,103 @@ if( modelFile == "quad2-small.meta" ) { tolerance = 10e-10; - double quad2smallExpectedSolution[8] = - { - 0, 0, - 2.97334e-07, -1.20555e-06, - 1.944e-06, -1.32333e-06, - 0, 0 - }; - expectedSolution = &(quad2smallExpectedSolution[0]); + haveExpectedSolution = true; + expectedSolution[0] = 0; expectedSolution[1] = 0; + expectedSolution[2] = 2.97334e-07; expectedSolution[3] = -1.20555e-06; + expectedSolution[4] = 1.944e-06; expectedSolution[5] = -1.32333e-06; + expectedSolution[6] = 0; expectedSolution[7] = 0; } else if( modelFile == "quad2-strain.meta" ) { tolerance = 10e-10; - double quad2strainExpectedSolution[8] = - { - 0, 0, - 2.56204e-07, -1.02482e-06, - 1.67956e-06, -1.19562e-06, - 0, 0 - }; - expectedSolution = &(quad2strainExpectedSolution[0]); + haveExpectedSolution = true; + expectedSolution[0] = 0; expectedSolution[1] = 0; + expectedSolution[2] = 2.56204e-07; expectedSolution[3] = -1.02482e-06; + expectedSolution[4] = 1.67956e-06; expectedSolution[5] = -1.19562e-06; + expectedSolution[6] = 0; expectedSolution[7] = 0; } else if( modelFile == "quad4.meta" ) { tolerance = 10e-10; - double quad4ExpectedSolution[8] = - { - 0, 0, - 0, 0, - 0, 0, - 0, 0 - }; - expectedSolution = &(quad4ExpectedSolution[0]); + haveExpectedSolution = true; + expectedSolution[0] = 0; expectedSolution[1] = 0; + expectedSolution[2] = 0; expectedSolution[3] = 0; + expectedSolution[4] = 0; expectedSolution[5] = 0; + expectedSolution[6] = 0; expectedSolution[7] = 0; } else if( modelFile == "quad6-grav.meta" ) { tolerance = 10e-10; - double quad6gravExpectedSolution[8] = - { - 0, 0, - 0, 0, - -5.32164e-08, 1.59649e-07, - 5.32164e-08, 1.59649e-07 - }; - expectedSolution = &(quad6gravExpectedSolution[0]); + haveExpectedSolution = true; + expectedSolution[0] = 0; expectedSolution[1] = 0; + expectedSolution[2] = 0; expectedSolution[3] = 0; + expectedSolution[4] = -5.32164e-08; expectedSolution[5] = 1.59649e-07; + expectedSolution[6] = 5.32164e-08; expectedSolution[7] = 1.59649e-07; } else if( modelFile == "quad-lm.meta" ) { tolerance = 10e-7; - double quadlmExpectedSolution[8] = - { - 0, 0, - -8.76093e-05, -0.0135944, - -0.00420457, 0.00477804, - -0.0163679, -0.0360446, - }; - expectedSolution = &(quadlmExpectedSolution[0]); + haveExpectedSolution = true; + expectedSolution[0] = 0; expectedSolution[1] = 0; + expectedSolution[2] = -8.76093e-05; expectedSolution[3] = -0.0135944; + expectedSolution[4] = -0.00420457; expectedSolution[5] = 0.00477804; + expectedSolution[6] = -0.0163679; expectedSolution[7] = -0.0360446; } else if( modelFile == "trapezoid.meta" ) { tolerance = 10e-10; - double trapezoidExpectedSolution[8] = - { - 0, 0, - 0, 0, - 0, 0, - 0, 0 - }; - expectedSolution = &(trapezoidExpectedSolution[0]); + haveExpectedSolution = true; + expectedSolution[0] = 0; expectedSolution[1] = 0; + expectedSolution[2] = 0; expectedSolution[3] = 0; + expectedSolution[4] = 0; expectedSolution[5] = 0; + expectedSolution[6] = 0; expectedSolution[7] = 0; } else if( modelFile == "tri2.meta" ) { tolerance = 10e-6; - double tri2ExpectedSolution[8] = - { - 0, 0, - 9.86667e-07, -2.028e-05, - -9.76e-06, -5.67867e-05, - -2.87733e-05, -9.68267e-05 - }; - expectedSolution = &(tri2ExpectedSolution[0]); - + haveExpectedSolution = true; + expectedSolution[0] = 0; expectedSolution[1] = 0; + expectedSolution[2] = 9.86667e-07; expectedSolution[3] = -2.028e-05; + expectedSolution[4] = -9.76e-06; expectedSolution[5] = -5.67867e-05; + expectedSolution[6] = -2.87733e-05; expectedSolution[7] = -9.68267e-05; } else if( modelFile == "tri3.meta" ) { tolerance = 10e-10; - double tri3ExpectedSolution[6] = - { - 0, 0, - 0, 0, - 0, 0 - }; - expectedSolution = &(tri3ExpectedSolution[0]); + haveExpectedSolution = true; + expectedSolution[0] = 0; expectedSolution[1] = 0; + expectedSolution[2] = 0; expectedSolution[3] = 0; + expectedSolution[4] = 0; expectedSolution[5] = 0; } else if( modelFile == "tri3-e.meta" ) { tolerance = 10e-10; - double tri3eExpectedSolution[6] = - { - 0, 0, - 0, 0, - 0, 0 - }; - expectedSolution = &(tri3eExpectedSolution[0]); + haveExpectedSolution = true; + expectedSolution[0] = 0; expectedSolution[1] = 0; + expectedSolution[2] = 0; expectedSolution[3] = 0; + expectedSolution[4] = 0; expectedSolution[5] = 0; } else if( modelFile == "tri3-q.meta" ) { tolerance = 10e-9; - double tri3qExpectedSolution[12] = - { - 0, 0, - -3.315e-07, 1.57527e-06, - 4.98323e-06, 7.36775e-07, - -5.3625e-08, 2.18676e-06, - 8.32488e-07, 1.04065e-06, - 5.22113e-07, 2.42889e-06 - }; - expectedSolution = &(tri3qExpectedSolution[0]); + haveExpectedSolution = true; + expectedSolution[0] = 0; expectedSolution[1] = 0; + expectedSolution[2] = -3.315e-07; expectedSolution[3] = 1.57527e-06; + expectedSolution[4] = 4.98323e-06; expectedSolution[5] = 7.36775e-07; + expectedSolution[6] = -5.3625e-08; expectedSolution[7] = 2.18676e-06; + expectedSolution[8] = 8.32488e-07; expectedSolution[9] = 1.04065e-06; + expectedSolution[10] = 5.22113e-07; expectedSolution[11] = 2.42889e-06; } else if( modelFile == "truss.meta" ) { tolerance = 10e-7; - double trussExpectedSolution[11] = - { - 0, 0, -0.179399, - 0.00169764, -0.478397, 0, - 0.00339527, 0, 0.179399, - 0.392323, -0.505307 - }; - expectedSolution = &(trussExpectedSolution[0]); + haveExpectedSolution = true; + expectedSolution[0] = 0; expectedSolution[1] = 0; + expectedSolution[2] = -0.179399; expectedSolution[3] = 0.00169764; + expectedSolution[4] = -0.478397; expectedSolution[5] = 0; + expectedSolution[6] = 0.00339527; expectedSolution[7] = 0; + expectedSolution[8] = 0.179399; expectedSolution[9] = 0.392323; + expectedSolution[10] = -0.505307; } else { @@ -293,7 +262,7 @@ } else { - if( expectedSolution != NULL ) + if( haveExpectedSolution ) { bool testError = CheckDisplacements1(solver, s, expectedSolution, tolerance); if( testError ) --- debian-svn.orig/Modules/Numerics/FEM/test/itkFEMElement3DTest.cxx +++ debian-svn/Modules/Numerics/FEM/test/itkFEMElement3DTest.cxx @@ -92,7 +92,8 @@ femSO->GetFEMObject()->FinalizeMesh(); - double * expectedSolution = NULL; + double expectedSolution[24]; + bool haveExpectedSolution = false; bool foundError = false; std::string modelFile = itksys::SystemTools::GetFilenameName( argv[1] ); @@ -139,87 +140,88 @@ if( modelFile == "hexa2.meta" ) { tolerance = 10e-6; - double hex2expectedSolution[24] = - { - -0.086324, -0.00055514, 0.121079, - 0.0952793, -0.00331153, 0.114235, - 0.0727445, 0.00768949, -0.0394109, - -0.0774779, -0.0115562, -0.0325665, - 0, 0, 0.0713128, - 0, 0, 0.0734239, - 0.0439568, 0, 0.00211102, - -0.0397348, 0, 0 - }; - expectedSolution = &(hex2expectedSolution[0]); + haveExpectedSolution = true; + expectedSolution[0] = -0.086324; expectedSolution[1] = -0.00055514; + expectedSolution[2] = 0.121079; expectedSolution[3] = 0.0952793; + expectedSolution[4] = -0.00331153; expectedSolution[5] = 0.114235; + expectedSolution[6] = 0.0727445; expectedSolution[7] = 0.00768949; + expectedSolution[8] = -0.0394109; expectedSolution[9] = -0.0774779; + expectedSolution[10] = -0.0115562; expectedSolution[11] = -0.0325665; + expectedSolution[12] = 0; expectedSolution[13] = 0; + expectedSolution[14] = 0.0713128; expectedSolution[15] = 0; + expectedSolution[16] = 0; expectedSolution[17] = 0.0734239; + expectedSolution[18] = 0.0439568; expectedSolution[19] = 0; + expectedSolution[20] = 0.00211102; expectedSolution[21] = -0.0397348; + expectedSolution[22] = 0; expectedSolution[23] = 0; } else if( modelFile == "hexa3.meta" ) { tolerance = 10e-10; - double hex3ExpectedSolution[24] = - { - 0, 0, 0, - 0, 0, 0, - 0, 0, 0, - 0, 0, 0, - 0, 0, 0, - 0, 0, 0, - 0, 0, 0, - 0, 0, 0 - }; - expectedSolution = &(hex3ExpectedSolution[0]); + haveExpectedSolution = true; + expectedSolution[0] = 0; expectedSolution[1] = 0; + expectedSolution[2] = 0; expectedSolution[3] = 0; + expectedSolution[4] = 0; expectedSolution[5] = 0; + expectedSolution[6] = 0; expectedSolution[7] = 0; + expectedSolution[8] = 0; expectedSolution[9] = 0; + expectedSolution[10] = 0; expectedSolution[11] = 0; + expectedSolution[12] = 0; expectedSolution[13] = 0; + expectedSolution[14] = 0; expectedSolution[15] = 0; + expectedSolution[16] = 0; expectedSolution[17] = 0; + expectedSolution[18] = 0; expectedSolution[19] = 0; + expectedSolution[20] = 0; expectedSolution[21] = 0; + expectedSolution[22] = 0; expectedSolution[23] = 0; } else if( modelFile == "hexa4-grav.meta" ) { tolerance = 10e-10; - double hex4GravExpectedSolution[24] = - { - 0, 0, 0, - 0, 0, 0, - 0, 0, 0, - 9.27489e-08, 2.95922e-06, -9.27489e-08, - -1.49661e-06, 8.59118e-07, 1.38971e-06, - -1.32956e-06, -5.70152e-07, 1.32956e-06, - -1.38971e-06, 8.59118e-07, 1.49661e-06, - -1.59154e-06, 2.37079e-06, 1.59154e-06 - }; - expectedSolution = &(hex4GravExpectedSolution[0]); + haveExpectedSolution = true; + expectedSolution[0] = 0; expectedSolution[1] = 0; + expectedSolution[2] = 0; expectedSolution[3] = 0; + expectedSolution[4] = 0; expectedSolution[5] = 0; + expectedSolution[6] = 0; expectedSolution[7] = 0; + expectedSolution[8] = 0; expectedSolution[9] = 9.27489e-08; + expectedSolution[10] = 2.95922e-06; expectedSolution[11] = -9.27489e-08; + expectedSolution[12] = -1.49661e-06; expectedSolution[13] = 8.59118e-07; + expectedSolution[14] = 1.38971e-06; expectedSolution[15] = -1.32956e-06; + expectedSolution[16] = -5.70152e-07; expectedSolution[17] = 1.32956e-06; + expectedSolution[18] = -1.38971e-06; expectedSolution[19] = 8.59118e-07; + expectedSolution[20] = 1.49661e-06; expectedSolution[21] = -1.59154e-06; + expectedSolution[22] = 2.37079e-06; expectedSolution[23] = 1.59154e-06; } else if( modelFile == "tetra2.meta" ) { tolerance = 10e-9; - double tetra2ExpectedSolution[15] = - { - 0, 0, 0, - 0, 0, -0.000866667, - 0, 0, -0.000866667, - 0, 0, 0, - 0, 0, 0 - }; - expectedSolution = &(tetra2ExpectedSolution[0]); + haveExpectedSolution = true; + expectedSolution[0] = 0; expectedSolution[1] = 0; + expectedSolution[2] = 0; expectedSolution[3] = 0; + expectedSolution[4] = 0; expectedSolution[5] = -0.000866667; + expectedSolution[6] = 0; expectedSolution[7] = 0; + expectedSolution[8] = -0.000866667; expectedSolution[9] = 0; + expectedSolution[10] = 0; expectedSolution[11] = 0; + expectedSolution[12] = 0; expectedSolution[13] = 0; + expectedSolution[14] = 0; } else if( modelFile == "tetra3.meta" ) { tolerance = 10e-10; - double tetra3ExpectedSolution[12] = - { - 0, 0, 0, - 0, 0, 0, - 0, 0, 0, - 0, 0, 0 - }; - expectedSolution = &(tetra3ExpectedSolution[0]); + haveExpectedSolution = true; + expectedSolution[0] = 0; expectedSolution[1] = 0; + expectedSolution[2] = 0; expectedSolution[3] = 0; + expectedSolution[4] = 0; expectedSolution[5] = 0; + expectedSolution[6] = 0; expectedSolution[7] = 0; + expectedSolution[8] = 0; expectedSolution[9] = 0; + expectedSolution[10] = 0; expectedSolution[11] = 0; } else if( modelFile == "tetra4-grav.meta" ) { tolerance = 10e-9; - double tetra4gravExpectedSolution[12] = - { - 0, 0, 0, - 0, 0, 0, - 0, 0, 0, - 0, 0, 1.46858e-05 - }; - expectedSolution = &(tetra4gravExpectedSolution[0]); + haveExpectedSolution = true; + expectedSolution[0] = 0; expectedSolution[1] = 0; + expectedSolution[2] = 0; expectedSolution[3] = 0; + expectedSolution[4] = 0; expectedSolution[5] = 0; + expectedSolution[6] = 0; expectedSolution[7] = 0; + expectedSolution[8] = 0; expectedSolution[9] = 0; + expectedSolution[10] = 0; expectedSolution[11] = 1.46858e-05; } else { @@ -231,7 +233,7 @@ PrintNodalCoordinates1(solver, s); // PrintU(S, s, ); - if( expectedSolution != NULL ) + if( haveExpectedSolution ) { bool testError = CheckDisplacements1(solver, s, expectedSolution, tolerance); if( testError )