← Back to team overview

dolfin team mailing list archive

[996357@xxxxxxxxxxxxxxxxxx: [Bug 996357] Re: Abuse of static_cast in VertexIterator]

 

Any implications on the speed of iteration?

--
Anders
--- Begin Message ---
** Changed in: dolfin
       Status: New => Fix Committed

-- 
You received this bug notification because you are a member of DOLFIN
Core Team, which is subscribed to DOLFIN.
https://bugs.launchpad.net/bugs/996357

Title:
  Abuse of static_cast in VertexIterator

Status in DOLFIN:
  Fix Committed

Bug description:
  I've installed fenics 1.0.0 using dorsal 1.0.0. Now consider the simple program
  ==================================================
  #include <dolfin.h>

  int main() {
  	dolfin::UnitSquare coarse(1,1);

  	for( dolfin::VertexIterator v(coarse); !v.end(); ++v)
  		assert(v->x(1) == v->x(1));

  	return 0;
  }
  ==================================================

  The assert fails if it is compiled and executed with

  cmake -D CMAKE_BUILD_TYPE=RelWithDebInfo . && make clean && make &&
  ./main

  (flags: -O2 -g). With

  cmake -D CMAKE_BUILD_TYPE=Debug . && make clean && make && ./main

  (flags: -g, without optimization) everything runs fine.

  
  In a larger project, this bug occurs also with "CMAKE_BUILD_TYPE=Debug", but I cannot reproduce it in this example. Due to this bug mesh refinement or snapping the boundary of a mesh results in strange, unfeasible meshes. I guessed that this is related to access to uninitialized/unallocated memory, but valgrind finds only some "errors" deep inside MPI:

  ==================================================
  $ valgrind --undef-value-errors=yes --track-origins=yes ./main
  ==5272== Memcheck, a memory error detector
  ==5272== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
  ==5272== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info
  ==5272== Command: ./main
  ==5272== 
  ==5272== Syscall param sched_setaffinity(mask) points to unaddressable byte(s)
  ==5272==    at 0xE301279: syscall (in /lib64/libc-2.11.3.so)
  ==5272==    by 0x102AA568: opal_paffinity_linux_plpa_api_probe_init (in /usr/local/FEniCS/1.0.0/lib/openmpi/mca_paffinity_linux.so)
  ==5272==    by 0x102AAC1C: opal_paffinity_linux_plpa_init (in /usr/local/FEniCS/1.0.0/lib/openmpi/mca_paffinity_linux.so)
  ==5272==    by 0x102AB789: opal_paffinity_linux_plpa_have_topology_information (in /usr/local/FEniCS/1.0.0/lib/openmpi/mca_paffinity_linux.so)
  ==5272==    by 0x102AA3FF: linux_module_init (in /usr/local/FEniCS/1.0.0/lib/openmpi/mca_paffinity_linux.so)
  ==5272==    by 0xCE5741E: opal_paffinity_base_select (in /usr/local/FEniCS/1.0.0/lib/libopen-pal.so.0.0.0)
  ==5272==    by 0xCE2A6D6: opal_init (in /usr/local/FEniCS/1.0.0/lib/libopen-pal.so.0.0.0)
  ==5272==    by 0xCBD697C: orte_init (in /usr/local/FEniCS/1.0.0/lib/libopen-rte.so.0.0.0)
  ==5272==    by 0xC952C26: ompi_mpi_init (in /usr/local/FEniCS/1.0.0/lib/libmpi.so.0.0.3)
  ==5272==    by 0xC9724D3: MPI_Init (in /usr/local/FEniCS/1.0.0/lib/libmpi.so.0.0.3)
  ==5272==    by 0x5023D10: dolfin::SubSystemsManager::init_mpi() (functions_inln.h:105)
  ==5272==    by 0x5024248: dolfin::MPI::num_processes() (MPI.cpp:59)
  ==5272==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
  ==5272== 
  ==5272== Syscall param writev(vector[...]) points to uninitialised byte(s)
  ==5272==    at 0xE2FD231: writev (in /lib64/libc-2.11.3.so)
  ==5272==    by 0x114C6C02: mca_oob_tcp_msg_send_handler (in /usr/local/FEniCS/1.0.0/lib/openmpi/mca_oob_tcp.so)
  ==5272==    by 0x114C782C: mca_oob_tcp_peer_send (in /usr/local/FEniCS/1.0.0/lib/openmpi/mca_oob_tcp.so)
  ==5272==    by 0x114CAD8C: mca_oob_tcp_send_nb (in /usr/local/FEniCS/1.0.0/lib/openmpi/mca_oob_tcp.so)
  ==5272==    by 0x10EB7C12: orte_rml_oob_send_buffer (in /usr/local/FEniCS/1.0.0/lib/openmpi/mca_rml_oob.so)
  ==5272==    by 0x118D5E63: allgather (in /usr/local/FEniCS/1.0.0/lib/openmpi/mca_grpcomm_bad.so)
  ==5272==    by 0x118D5489: modex (in /usr/local/FEniCS/1.0.0/lib/openmpi/mca_grpcomm_bad.so)
  ==5272==    by 0xC953416: ompi_mpi_init (in /usr/local/FEniCS/1.0.0/lib/libmpi.so.0.0.3)
  ==5272==    by 0xC9724D3: MPI_Init (in /usr/local/FEniCS/1.0.0/lib/libmpi.so.0.0.3)
  ==5272==    by 0x5023D10: dolfin::SubSystemsManager::init_mpi() (functions_inln.h:105)
  ==5272==    by 0x5024248: dolfin::MPI::num_processes() (MPI.cpp:59)
  ==5272==    by 0x50242A8: dolfin::MPI::is_receiver() (MPI.cpp:72)
  ==5272==  Address 0x12059db7 is 87 bytes inside a block of size 256 alloc'd
  ==5272==    at 0x4C26922: realloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==5272==    by 0xCE2B8C2: opal_dss_buffer_extend (in /usr/local/FEniCS/1.0.0/lib/libopen-pal.so.0.0.0)
  ==5272==    by 0xCE2C3BD: opal_dss_copy_payload (in /usr/local/FEniCS/1.0.0/lib/libopen-pal.so.0.0.0)
  ==5272==    by 0x118D5E38: allgather (in /usr/local/FEniCS/1.0.0/lib/openmpi/mca_grpcomm_bad.so)
  ==5272==    by 0x118D5489: modex (in /usr/local/FEniCS/1.0.0/lib/openmpi/mca_grpcomm_bad.so)
  ==5272==    by 0xC953416: ompi_mpi_init (in /usr/local/FEniCS/1.0.0/lib/libmpi.so.0.0.3)
  ==5272==    by 0xC9724D3: MPI_Init (in /usr/local/FEniCS/1.0.0/lib/libmpi.so.0.0.3)
  ==5272==    by 0x5023D10: dolfin::SubSystemsManager::init_mpi() (functions_inln.h:105)
  ==5272==    by 0x5024248: dolfin::MPI::num_processes() (MPI.cpp:59)
  ==5272==    by 0x50242A8: dolfin::MPI::is_receiver() (MPI.cpp:72)
  ==5272==    by 0x527CC8F: dolfin::UnitSquare::UnitSquare(unsigned int, unsigned int, std::string) (UnitSquare.cpp:35)
  ==5272==    by 0x40B2EF: main (main.cpp:4)
  ==5272==  Uninitialised value was created by a heap allocation
  ==5272==    at 0x4C2683D: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==5272==    by 0xCE43FBB: opal_ifinit (in /usr/local/FEniCS/1.0.0/lib/libopen-pal.so.0.0.0)
  ==5272==    by 0xCE449E8: opal_ifcount (in /usr/local/FEniCS/1.0.0/lib/libopen-pal.so.0.0.0)
  ==5272==    by 0x114C5ABE: mca_oob_tcp_component_init (in /usr/local/FEniCS/1.0.0/lib/openmpi/mca_oob_tcp.so)
  ==5272==    by 0xCBFC2BD: mca_oob_base_init (in /usr/local/FEniCS/1.0.0/lib/libopen-rte.so.0.0.0)
  ==5272==    by 0x10EB58CA: rml_oob_init (in /usr/local/FEniCS/1.0.0/lib/openmpi/mca_rml_oob.so)
  ==5272==    by 0xCC02904: orte_rml_base_select (in /usr/local/FEniCS/1.0.0/lib/libopen-rte.so.0.0.0)
  ==5272==    by 0xCBF0254: orte_ess_base_app_setup (in /usr/local/FEniCS/1.0.0/lib/libopen-rte.so.0.0.0)
  ==5272==    by 0x112BDFE0: rte_init (in /usr/local/FEniCS/1.0.0/lib/openmpi/mca_ess_singleton.so)
  ==5272==    by 0xCBD6AE2: orte_init (in /usr/local/FEniCS/1.0.0/lib/libopen-rte.so.0.0.0)
  ==5272==    by 0xC952C26: ompi_mpi_init (in /usr/local/FEniCS/1.0.0/lib/libmpi.so.0.0.3)
  ==5272==    by 0xC9724D3: MPI_Init (in /usr/local/FEniCS/1.0.0/lib/libmpi.so.0.0.3)
  ==5272== 
  main: /HOME1/users/personal/gerw/spielwiese/MeshRefinement/main.cpp:7: int main(): Assertion `v->x(1) == v->x(1)' failed.
  [romulus:05272] *** Process received signal ***
  [romulus:05272] Signal: Aborted (6)
  [romulus:05272] Signal code:  (-6)
  [romulus:05272] [ 0] /lib64/libpthread.so.0(+0xf2d0) [0xe0232d0]
  [romulus:05272] [ 1] /lib64/libc.so.6(gsignal+0x35) [0xe263ab5]
  [romulus:05272] [ 2] /lib64/libc.so.6(abort+0x186) [0xe264fb6]
  [romulus:05272] [ 3] /lib64/libc.so.6(__assert_fail+0xf5) [0xe25c385]
  [romulus:05272] [ 4] ./main(main+0x236) [0x40b4e6]
  [romulus:05272] [ 5] /lib64/libc.so.6(__libc_start_main+0xfd) [0xe24fbfd]
  [romulus:05272] [ 6] ./main() [0x40b1e9]
  [romulus:05272] *** End of error message ***
  ==5272== Invalid free() / delete / delete[]
  ==5272==    at 0x4C2599C: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==5272==    by 0xE34794A: free_mem (in /lib64/libc-2.11.3.so)
  ==5272==    by 0xE3474F1: __libc_freeres (in /lib64/libc-2.11.3.so)
  ==5272==    by 0x4A205EC: _vgnU_freeres (in /usr/lib64/valgrind/vgpreload_core-amd64-linux.so)
  ==5272==    by 0xE264F46: abort (in /lib64/libc-2.11.3.so)
  ==5272==    by 0xE25C384: __assert_fail (in /lib64/libc-2.11.3.so)
  ==5272==    by 0x40B4E5: main (main.cpp:7)
  ==5272==  Address 0x405fb48 is not stack'd, malloc'd or (recently) free'd
  ==5272== 
  ==5272== 
  ==5272== HEAP SUMMARY:
  ==5272==     in use at exit: 2,182,678 bytes in 3,463 blocks
  ==5272==   total heap usage: 12,322 allocs, 8,861 frees, 15,730,246 bytes allocated
  ==5272== 
  ==5272== LEAK SUMMARY:
  ==5272==    definitely lost: 1,228 bytes in 16 blocks
  ==5272==    indirectly lost: 2,637 bytes in 9 blocks
  ==5272==      possibly lost: 15,884 bytes in 316 blocks
  ==5272==    still reachable: 2,162,929 bytes in 3,122 blocks
  ==5272==         suppressed: 0 bytes in 0 blocks
  ==5272== Rerun with --leak-check=full to see details of leaked memory
  ==5272== 
  ==5272== For counts of detected and suppressed errors, rerun with: -v
  ==5272== ERROR SUMMARY: 4 errors from 3 contexts (suppressed: 4 from 4)
  ==================================================
  If it matters:

  $ gcc --version
  gcc (SUSE Linux) 4.5.1 20101208 [gcc-4_5-branch revision 167585]

To manage notifications about this bug go to:
https://bugs.launchpad.net/dolfin/+bug/996357/+subscriptions

--- End Message ---

Follow ups