Skip to content

Segfault and valgrind errors #125

Description

@nh2

With the versions from #120 (comment), I sometimes (nondeterministically, see also #124) get segfault, and valgrind reports Invalid read of size 4:

Details
# OMP_THREAD_LIMIT=1 valgrind bin/texrecon scene/::undistorted ~/small2.ply ~/texrecon-out-small-new2/outprefix --keep_unseen_faces --outlier_removal=gauss_damping --skip_geometric_visibility_test
==20303== Memcheck, a memory error detector
==20303== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==20303== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info
==20303== Command: bin/texrecon scene/::undistorted /root/small2.ply /root/texrecon-out-small-new2/outprefix --keep_unseen_faces --outlier_removal=gauss_damping --skip_geometric_visibility_test
==20303== 
bin/texrecon (built on Jan  1 1970, 00:00:01)
Load and prepare mesh: 
PLY Loader: comment VCGLIB generated
Reading PLY: 5150 verts... 5937 faces... done.
Generating texture views: 
Initializing scene with 2215 views...
Initialized 2215 views (max ID is 2214), took 2071ms.
        Loading 100%... done. (Took 0.54s)                                      
Building adjacency graph: 
        Adding edges 100%... done. (Took 0.232s)                                
  7068 total edges.
View selection:
  Building BVH from 5937 faces... done. (Took: 617 ms)
        Calculating face qualities 100%... done. (Took 219.853s)                
        Postprocessing face infos 100%... done. (Took 27.302s)                  
  Maximum quality of a face within an image: 1136.17
  Clamping qualities to 67.0405 within normalization.
  Writing data cost file... done.
  Optimizing:
    Time[s] Energy
    0 2462
    2 2432
    3 2395
    3 2369
    4 2364
    4 2362
    5 2361
    6 2360
    7 2360
    7 2360
    8 2360
    9 2360
    9 2360
    10  2360
  1 faces have not been seen
  Took: 262.587s
Generating texture patches:
  Running... done. (Took 69.704s)
  366 texture patches.
Running global seam leveling:
  Create matrices for optimization...  done.
  Lhs dimensionality: 5191 x 5191
  Calculating adjustments:
    Color channel 0: CG took 31 iterations. Residual is 8.52602e-05
    Color channel 1: CG took 31 iterations. Residual is 8.46199e-05
    Color channel 2: CG took 31 iterations. Residual is 8.38964e-05
    Took 0.184 seconds
        Adjusting texture patches 100%... done. (Took 8.399s)                   
Running local seam leveling:
        Blending texture patches 100%...==20303== Invalid read of size 4        
==20303==    at 0x549136: poisson_blend(std::shared_ptr<mve::Image<float> const>, std::shared_ptr<mve::Image<unsigned char> const>, std::shared_ptr<mve::Image<float> >, float) (in bin/texrecon)
==20303==    by 0x4DF5A3: TexturePatch::blend(std::shared_ptr<mve::Image<float> const>) (in bin/texrecon)
==20303==    by 0x4D35AB: tex::local_seam_leveling(UniGraph const&, std::shared_ptr<mve::TriangleMesh const>, std::vector<std::vector<tex::VertexProjectionInfo, std::allocator<tex::VertexProjectionInfo> >, std::allocator<std::vector<tex::VertexProjectionInfo, std::allocator<tex::VertexProjectionInfo> > > > const&, std::vector<std::shared_ptr<TexturePatch>, std::allocator<std::shared_ptr<TexturePatch> > >*) [clone ._omp_fn.0] (in bin/texrecon)
==20303==    by 0x607BDAE: GOMP_parallel (in gcc-7.3.0-lib/lib/libgomp.so.1.0.0)
==20303==    by 0x4D575A: tex::local_seam_leveling(UniGraph const&, std::shared_ptr<mve::TriangleMesh const>, std::vector<std::vector<tex::VertexProjectionInfo, std::allocator<tex::VertexProjectionInfo> >, std::allocator<std::vector<tex::VertexProjectionInfo, std::allocator<tex::VertexProjectionInfo> > > > const&, std::vector<std::shared_ptr<TexturePatch>, std::allocator<std::shared_ptr<TexturePatch> > >*) (in bin/texrecon)
==20303==    by 0x44D7C5: main (in bin/texrecon)
==20303==  Address 0x7d8abc8 is 4 bytes after a block of size 36 alloc'd
==20303==    at 0x4C2D1AF: operator new(unsigned long) (in valgrind-3.13.0/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==20303==    by 0x54AAA7: poisson_blend(std::shared_ptr<mve::Image<float> const>, std::shared_ptr<mve::Image<unsigned char> const>, std::shared_ptr<mve::Image<float> >, float) (in bin/texrecon)
==20303==    by 0x4DF5A3: TexturePatch::blend(std::shared_ptr<mve::Image<float> const>) (in bin/texrecon)
==20303==    by 0x4D35AB: tex::local_seam_leveling(UniGraph const&, std::shared_ptr<mve::TriangleMesh const>, std::vector<std::vector<tex::VertexProjectionInfo, std::allocator<tex::VertexProjectionInfo> >, std::allocator<std::vector<tex::VertexProjectionInfo, std::allocator<tex::VertexProjectionInfo> > > > const&, std::vector<std::shared_ptr<TexturePatch>, std::allocator<std::shared_ptr<TexturePatch> > >*) [clone ._omp_fn.0] (in bin/texrecon)
==20303==    by 0x607BDAE: GOMP_parallel (in gcc-7.3.0-lib/lib/libgomp.so.1.0.0)
==20303==    by 0x4D575A: tex::local_seam_leveling(UniGraph const&, std::shared_ptr<mve::TriangleMesh const>, std::vector<std::vector<tex::VertexProjectionInfo, std::allocator<tex::VertexProjectionInfo> >, std::allocator<std::vector<tex::VertexProjectionInfo, std::allocator<tex::VertexProjectionInfo> > > > const&, std::vector<std::shared_ptr<TexturePatch>, std::allocator<std::shared_ptr<TexturePatch> > >*) (in bin/texrecon)
==20303==    by 0x44D7C5: main (in bin/texrecon)
==20303== 
==20303== Invalid read of size 8
==20303==    at 0x5487FF: simple_laplacian(int, std::shared_ptr<mve::Image<float> const>) (in bin/texrecon)
==20303==    by 0x549217: poisson_blend(std::shared_ptr<mve::Image<float> const>, std::shared_ptr<mve::Image<unsigned char> const>, std::shared_ptr<mve::Image<float> >, float) (in bin/texrecon)
==20303==    by 0x4DF5A3: TexturePatch::blend(std::shared_ptr<mve::Image<float> const>) (in bin/texrecon)
==20303==    by 0x4D35AB: tex::local_seam_leveling(UniGraph const&, std::shared_ptr<mve::TriangleMesh const>, std::vector<std::vector<tex::VertexProjectionInfo, std::allocator<tex::VertexProjectionInfo> >, std::allocator<std::vector<tex::VertexProjectionInfo, std::allocator<tex::VertexProjectionInfo> > > > const&, std::vector<std::shared_ptr<TexturePatch>, std::allocator<std::shared_ptr<TexturePatch> > >*) [clone ._omp_fn.0] (in bin/texrecon)
==20303==    by 0x607BDAE: GOMP_parallel (in gcc-7.3.0-lib/lib/libgomp.so.1.0.0)
==20303==    by 0x4D575A: tex::local_seam_leveling(UniGraph const&, std::shared_ptr<mve::TriangleMesh const>, std::vector<std::vector<tex::VertexProjectionInfo, std::allocator<tex::VertexProjectionInfo> >, std::allocator<std::vector<tex::VertexProjectionInfo, std::allocator<tex::VertexProjectionInfo> > > > const&, std::vector<std::shared_ptr<TexturePatch>, std::allocator<std::shared_ptr<TexturePatch> > >*) (in bin/texrecon)
==20303==    by 0x44D7C5: main (in bin/texrecon)
==20303==  Address 0x7f651f8 is 12 bytes after a block of size 108 alloc'd
==20303==    at 0x4C2D1AF: operator new(unsigned long) (in valgrind-3.13.0/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==20303==    by 0x4821D9: tex::generate_texture_patches(UniGraph const&, std::shared_ptr<mve::TriangleMesh const>, mve::MeshInfo const&, std::vector<tex::TextureView, std::allocator<tex::TextureView> >*, tex::Settings const&, std::vector<std::vector<tex::VertexProjectionInfo, std::allocator<tex::VertexProjectionInfo> >, std::allocator<std::vector<tex::VertexProjectionInfo, std::allocator<tex::VertexProjectionInfo> > > >*, std::vector<std::shared_ptr<TexturePatch>, std::allocator<std::shared_ptr<TexturePatch> > >*) (in bin/texrecon)
==20303==    by 0x44D696: main (in bin/texrecon)
==20303== 
==20303== Invalid read of size 4
==20303==    at 0x548802: simple_laplacian(int, std::shared_ptr<mve::Image<float> const>) (in bin/texrecon)
==20303==    by 0x549217: poisson_blend(std::shared_ptr<mve::Image<float> const>, std::shared_ptr<mve::Image<unsigned char> const>, std::shared_ptr<mve::Image<float> >, float) (in bin/texrecon)
==20303==    by 0x4DF5A3: TexturePatch::blend(std::shared_ptr<mve::Image<float> const>) (in bin/texrecon)
==20303==    by 0x4D35AB: tex::local_seam_leveling(UniGraph const&, std::shared_ptr<mve::TriangleMesh const>, std::vector<std::vector<tex::VertexProjectionInfo, std::allocator<tex::VertexProjectionInfo> >, std::allocator<std::vector<tex::VertexProjectionInfo, std::allocator<tex::VertexProjectionInfo> > > > const&, std::vector<std::shared_ptr<TexturePatch>, std::allocator<std::shared_ptr<TexturePatch> > >*) [clone ._omp_fn.0] (in bin/texrecon)
==20303==    by 0x607BDAE: GOMP_parallel (in gcc-7.3.0-lib/lib/libgomp.so.1.0.0)
==20303==    by 0x4D575A: tex::local_seam_leveling(UniGraph const&, std::shared_ptr<mve::TriangleMesh const>, std::vector<std::vector<tex::VertexProjectionInfo, std::allocator<tex::VertexProjectionInfo> >, std::allocator<std::vector<tex::VertexProjectionInfo, std::allocator<tex::VertexProjectionInfo> > > > const&, std::vector<std::shared_ptr<TexturePatch>, std::allocator<std::shared_ptr<TexturePatch> > >*) (in bin/texrecon)
==20303==    by 0x44D7C5: main (in bin/texrecon)
==20303==  Address 0x7f65200 is 20 bytes after a block of size 108 alloc'd
==20303==    at 0x4C2D1AF: operator new(unsigned long) (in valgrind-3.13.0/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==20303==    by 0x4821D9: tex::generate_texture_patches(UniGraph const&, std::shared_ptr<mve::TriangleMesh const>, mve::MeshInfo const&, std::vector<tex::TextureView, std::allocator<tex::TextureView> >*, tex::Settings const&, std::vector<std::vector<tex::VertexProjectionInfo, std::allocator<tex::VertexProjectionInfo> >, std::allocator<std::vector<tex::VertexProjectionInfo, std::allocator<tex::VertexProjectionInfo> > > >*, std::vector<std::shared_ptr<TexturePatch>, std::allocator<std::shared_ptr<TexturePatch> > >*) (in bin/texrecon)
==20303==    by 0x44D696: main (in bin/texrecon)
==20303== 
==20303== Invalid read of size 8
==20303==    at 0x5487FF: simple_laplacian(int, std::shared_ptr<mve::Image<float> const>) (in bin/texrecon)
==20303==    by 0x549286: poisson_blend(std::shared_ptr<mve::Image<float> const>, std::shared_ptr<mve::Image<unsigned char> const>, std::shared_ptr<mve::Image<float> >, float) (in bin/texrecon)
==20303==    by 0x4DF5A3: TexturePatch::blend(std::shared_ptr<mve::Image<float> const>) (in bin/texrecon)
==20303==    by 0x4D35AB: tex::local_seam_leveling(UniGraph const&, std::shared_ptr<mve::TriangleMesh const>, std::vector<std::vector<tex::VertexProjectionInfo, std::allocator<tex::VertexProjectionInfo> >, std::allocator<std::vector<tex::VertexProjectionInfo, std::allocator<tex::VertexProjectionInfo> > > > const&, std::vector<std::shared_ptr<TexturePatch>, std::allocator<std::shared_ptr<TexturePatch> > >*) [clone ._omp_fn.0] (in bin/texrecon)
==20303==    by 0x607BDAE: GOMP_parallel (in gcc-7.3.0-lib/lib/libgomp.so.1.0.0)
==20303==    by 0x4D575A: tex::local_seam_leveling(UniGraph const&, std::shared_ptr<mve::TriangleMesh const>, std::vector<std::vector<tex::VertexProjectionInfo, std::allocator<tex::VertexProjectionInfo> >, std::allocator<std::vector<tex::VertexProjectionInfo, std::allocator<tex::VertexProjectionInfo> > > > const&, std::vector<std::shared_ptr<TexturePatch>, std::allocator<std::shared_ptr<TexturePatch> > >*) (in bin/texrecon)
==20303==    by 0x44D7C5: main (in bin/texrecon)
==20303==  Address 0x7df6c68 is 12 bytes after a block of size 108 alloc'd
==20303==    at 0x4C2D1AF: operator new(unsigned long) (in valgrind-3.13.0/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==20303==    by 0x4D2E52: tex::local_seam_leveling(UniGraph const&, std::shared_ptr<mve::TriangleMesh const>, std::vector<std::vector<tex::VertexProjectionInfo, std::allocator<tex::VertexProjectionInfo> >, std::allocator<std::vector<tex::VertexProjectionInfo, std::allocator<tex::VertexProjectionInfo> > > > const&, std::vector<std::shared_ptr<TexturePatch>, std::allocator<std::shared_ptr<TexturePatch> > >*) [clone ._omp_fn.0] (in bin/texrecon)
==20303==    by 0x607BDAE: GOMP_parallel (in gcc-7.3.0-lib/lib/libgomp.so.1.0.0)
==20303==    by 0x4D575A: tex::local_seam_leveling(UniGraph const&, std::shared_ptr<mve::TriangleMesh const>, std::vector<std::vector<tex::VertexProjectionInfo, std::allocator<tex::VertexProjectionInfo> >, std::allocator<std::vector<tex::VertexProjectionInfo, std::allocator<tex::VertexProjectionInfo> > > > const&, std::vector<std::shared_ptr<TexturePatch>, std::allocator<std::shared_ptr<TexturePatch> > >*) (in bin/texrecon)
==20303==    by 0x44D7C5: main (in bin/texrecon)
==20303== 
==20303== Invalid read of size 4
==20303==    at 0x548802: simple_laplacian(int, std::shared_ptr<mve::Image<float> const>) (in bin/texrecon)
==20303==    by 0x549286: poisson_blend(std::shared_ptr<mve::Image<float> const>, std::shared_ptr<mve::Image<unsigned char> const>, std::shared_ptr<mve::Image<float> >, float) (in bin/texrecon)
==20303==    by 0x4DF5A3: TexturePatch::blend(std::shared_ptr<mve::Image<float> const>) (in bin/texrecon)
==20303==    by 0x4D35AB: tex::local_seam_leveling(UniGraph const&, std::shared_ptr<mve::TriangleMesh const>, std::vector<std::vector<tex::VertexProjectionInfo, std::allocator<tex::VertexProjectionInfo> >, std::allocator<std::vector<tex::VertexProjectionInfo, std::allocator<tex::VertexProjectionInfo> > > > const&, std::vector<std::shared_ptr<TexturePatch>, std::allocator<std::shared_ptr<TexturePatch> > >*) [clone ._omp_fn.0] (in bin/texrecon)
==20303==    by 0x607BDAE: GOMP_parallel (in gcc-7.3.0-lib/lib/libgomp.so.1.0.0)
==20303==    by 0x4D575A: tex::local_seam_leveling(UniGraph const&, std::shared_ptr<mve::TriangleMesh const>, std::vector<std::vector<tex::VertexProjectionInfo, std::allocator<tex::VertexProjectionInfo> >, std::allocator<std::vector<tex::VertexProjectionInfo, std::allocator<tex::VertexProjectionInfo> > > > const&, std::vector<std::shared_ptr<TexturePatch>, std::allocator<std::shared_ptr<TexturePatch> > >*) (in bin/texrecon)
==20303==    by 0x44D7C5: main (in bin/texrecon)
==20303==  Address 0x7df6c70 is 20 bytes after a block of size 108 alloc'd
==20303==    at 0x4C2D1AF: operator new(unsigned long) (in valgrind-3.13.0/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==20303==    by 0x4D2E52: tex::local_seam_leveling(UniGraph const&, std::shared_ptr<mve::TriangleMesh const>, std::vector<std::vector<tex::VertexProjectionInfo, std::allocator<tex::VertexProjectionInfo> >, std::allocator<std::vector<tex::VertexProjectionInfo, std::allocator<tex::VertexProjectionInfo> > > > const&, std::vector<std::shared_ptr<TexturePatch>, std::allocator<std::shared_ptr<TexturePatch> > >*) [clone ._omp_fn.0] (in bin/texrecon)
==20303==    by 0x607BDAE: GOMP_parallel (in gcc-7.3.0-lib/lib/libgomp.so.1.0.0)
==20303==    by 0x4D575A: tex::local_seam_leveling(UniGraph const&, std::shared_ptr<mve::TriangleMesh const>, std::vector<std::vector<tex::VertexProjectionInfo, std::allocator<tex::VertexProjectionInfo> >, std::allocator<std::vector<tex::VertexProjectionInfo, std::allocator<tex::VertexProjectionInfo> > > > const&, std::vector<std::shared_ptr<TexturePatch>, std::allocator<std::shared_ptr<TexturePatch> > >*) (in bin/texrecon)
==20303==    by 0x44D7C5: main (in bin/texrecon)
==20303== 
==20303== Invalid read of size 4
==20303==    at 0x49BF03: Eigen::SparseMatrix<float, 1, int>::sumupDuplicates() (in bin/texrecon)
==20303==    by 0x49CCAA: void Eigen::internal::set_from_triplets<__gnu_cxx::__normal_iterator<Eigen::Triplet<float, int>*, std::vector<Eigen::Triplet<float, int>, std::allocator<Eigen::Triplet<float, int> > > >, Eigen::SparseMatrix<float, 0, int> >(__gnu_cxx::__normal_iterator<Eigen::Triplet<float, int>*, std::vector<Eigen::Triplet<float, int>, std::allocator<Eigen::Triplet<float, int> > > > const&, __gnu_cxx::__normal_iterator<Eigen::Triplet<float, int>*, std::vector<Eigen::Triplet<float, int>, std::allocator<Eigen::Triplet<float, int> > > > const&, Eigen::SparseMatrix<float, 0, int>&, int) (in bin/texrecon)
==20303==    by 0x549417: poisson_blend(std::shared_ptr<mve::Image<float> const>, std::shared_ptr<mve::Image<unsigned char> const>, std::shared_ptr<mve::Image<float> >, float) (in bin/texrecon)
==20303==    by 0x4DF5A3: TexturePatch::blend(std::shared_ptr<mve::Image<float> const>) (in bin/texrecon)
==20303==    by 0x4D35AB: tex::local_seam_leveling(UniGraph const&, std::shared_ptr<mve::TriangleMesh const>, std::vector<std::vector<tex::VertexProjectionInfo, std::allocator<tex::VertexProjectionInfo> >, std::allocator<std::vector<tex::VertexProjectionInfo, std::allocator<tex::VertexProjectionInfo> > > > const&, std::vector<std::shared_ptr<TexturePatch>, std::allocator<std::shared_ptr<TexturePatch> > >*) [clone ._omp_fn.0] (in bin/texrecon)
==20303==    by 0x607BDAE: GOMP_parallel (in gcc-7.3.0-lib/lib/libgomp.so.1.0.0)
==20303==    by 0x4D575A: tex::local_seam_leveling(UniGraph const&, std::shared_ptr<mve::TriangleMesh const>, std::vector<std::vector<tex::VertexProjectionInfo, std::allocator<tex::VertexProjectionInfo> >, std::allocator<std::vector<tex::VertexProjectionInfo, std::allocator<tex::VertexProjectionInfo> > > > const&, std::vector<std::shared_ptr<TexturePatch>, std::allocator<std::shared_ptr<TexturePatch> > >*) (in bin/texrecon)
==20303==    by 0x44D7C5: main (in bin/texrecon)
==20303==  Address 0xf932de04 is not stack'd, malloc'd or (recently) free'd
==20303== 
Received signal SIGSEGV (segmentation fault)
Obtained 12 stack frames: 0x588f44 0x67032d0 0x49bf03 0x49ccab 0x549418 0x4df5a4 0x4d35ac 0x607bdaf 0x4d575b 0x44d7c6 0x66f0020 0x4508ca
bin/texrecon(_ZN4util6system17print_stack_traceEv+0x34)[0x588f44]
glibc-2.26-131/lib/libc.so.6(+0x342d0)[0x67032d0]
bin/texrecon(_ZN5Eigen12SparseMatrixIfLi1EiE15sumupDuplicatesEv+0x3a3)[0x49bf03]
bin/texrecon(_ZN5Eigen8internal17set_from_tripletsIN9__gnu_cxx17__normal_iteratorIPNS_7TripletIfiEESt6vectorIS5_SaIS5_EEEENS_12SparseMatrixIfLi0EiEEEEvRKT_SF_RT0_i+0x7db)[0x49ccab]
bin/texrecon(_Z13poisson_blendSt10shared_ptrIKN3mve5ImageIfEEES_IKNS1_IhEEES_IS2_Ef+0x858)[0x549418]
bin/texrecon(_ZN12TexturePatch5blendESt10shared_ptrIKN3mve5ImageIfEEE+0x94)[0x4df5a4]
bin/texrecon[0x4d35ac]
gcc-7.3.0-lib/lib/libgomp.so.1(GOMP_parallel+0x3f)[0x607bdaf]
bin/texrecon(_ZN3tex19local_seam_levelingERK8UniGraphSt10shared_ptrIKN3mve12TriangleMeshEERKSt6vectorIS8_INS_20VertexProjectionInfoESaIS9_EESaISB_EEPS8_IS3_I12TexturePatchESaISH_EE+0x148b)[0x4d575b]
bin/texrecon(main+0xc36)[0x44d7c6]
glibc-2.26-131/lib/libc.so.6(__libc_start_main+0xf0)[0x66f0020]
bin/texrecon(_start+0x2a)[0x4508ca]
Segmentation fault
==20303== 
==20303== HEAP SUMMARY:
==20303==     in use at exit: 105,409,680 bytes in 154,282 blocks
==20303==   total heap usage: 4,718,202 allocs, 4,563,920 frees, 10,446,037,939 bytes allocated
==20303== 
==20303== LEAK SUMMARY:
==20303==    definitely lost: 3,570,646 bytes in 61,064 blocks
==20303==    indirectly lost: 1,560,816 bytes in 60,949 blocks
==20303==      possibly lost: 3,648 bytes in 26 blocks
==20303==    still reachable: 100,274,570 bytes in 32,243 blocks
==20303==                       of which reachable via heuristic:
==20303==                         newarray           : 6,168 bytes in 3 blocks
==20303==         suppressed: 0 bytes in 0 blocks
==20303== Rerun with --leak-check=full to see details of leaked memory
==20303== 
==20303== For counts of detected and suppressed errors, rerun with: -v
==20303== ERROR SUMMARY: 6 errors from 6 contexts (suppressed: 0 from 0)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions