Skip to content

Bug with MeshUseTopology

Continuing with the fuzzing, I found a conditional jump leading to a segfault when using the option MeshUseTopology

This is produced by the attached input/structures inp

structure.inc

when run on 3 MPI tasks.

The problem is clearly reported by Valgrind

==1297936== Conditional jump or move depends on uninitialised value(s)
==1297936==    at 0x85B347: do_partition.1 (mesh_init.F90:601)
==1297936==    by 0x864FE6: __mesh_init_oct_m_MOD_mesh_init_stage_3 (mesh_init.F90:466)
==1297936==    by 0x7C85D1: __grid_oct_m_MOD_grid_init_stage_2 (grid.F90:380)
==1297936==    by 0x60F448: __electrons_oct_m_MOD_electrons_init_parallelization (electrons.F90:387)
==1297936==    by 0x47A839: __run_oct_m_MOD_run (run.F90:177)
==1297936==    by 0x476A30: MAIN__ (main.F90:135)
==1297936==    by 0x40FA26: main (main.F90:23)
==1297936==  Uninitialised value was created by a heap allocation
==1297936==    at 0x48497B2: malloc (vg_replace_malloc.c:446)
==1297936==    by 0x85A507: do_partition.1 (mesh_init.F90:585)
==1297936==    by 0x864FE6: __mesh_init_oct_m_MOD_mesh_init_stage_3 (mesh_init.F90:466)
==1297936==    by 0x7C85D1: __grid_oct_m_MOD_grid_init_stage_2 (grid.F90:380)
==1297936==    by 0x60F448: __electrons_oct_m_MOD_electrons_init_parallelization (electrons.F90:387)
==1297936==    by 0x47A839: __run_oct_m_MOD_run (run.F90:177)
==1297936==    by 0x476A30: MAIN__ (main.F90:135)
==1297936==    by 0x40FA26: main (main.F90:23)

Looking at the code, part_vec is never initialized for mesh%np_global+1 to mesh%np_part_global. This most likely causes the bug.