The following "minimal example" causes a segfault if compiled with ifort 17.0.4 20170411 on 64-bit Linux (Ubuntu 16.04)
goerz@mlhpc2:~> uname -a
Linux mlhpc2 4.4.0-36-generic #55-Ubuntu SMP Thu Aug 11 18:01:55 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
This is on a machine with 80 cores, the CPU information on the highest core is
processor : 79
vendor_id : GenuineIntel
cpu family : 6
model : 47
model name : Intel(R) Xeon(R) CPU E7- 4870 @ 2.40GHz
stepping : 2
microcode : 0x37
cpu MHz : 1064.000
cache size : 30720 KB
physical id : 7
siblings : 10
core id : 9
cpu cores : 10
apicid : 242
initial apicid : 242
fpu : yes
fpu_exception : yes
cpuid level : 11
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2 popcnt aes lahf_lm epb tpr_shadow vnmi flexpriority ept vpid dtherm ida arat
bugs : clflush_monitor
bogomips : 4788.04
clflush size : 64
cache_alignment : 64
address sizes : 44 bits physical, 48 bits virtual
The program (see also attachment) reads as follows:
program test
implicit none
integer, parameter :: sparsity_model_l = 10
integer, parameter :: op_subspace_l = 5
!integer, parameter :: op_subspace_l = 10 ! This works
type op_matrix_t
character(len=sparsity_model_l) :: sparsity_model
character(len=op_subspace_l) :: subspace
end type op_matrix_t
type(op_matrix_t) :: obs
call debug_op_matrix_t(obs) ! works (but not needed)
obs%sparsity_model = '' ! commenting out either one ...
obs%subspace = '' ! ... of these lines makes it work
call debug_op_matrix_t(obs) ! crashes when printing subspace
contains
subroutine debug_op_matrix_t(var)
type(op_matrix_t), intent(in) :: var
write(*,'("obs = {")')
write(*,'(A,A,A)') ' sparsity_model', ' = ', "'"//trim(var%sparsity_model)//"'"
write(*,'(A,A,A)') ' subspace ', ' = ', "'"//trim(var%subspace)//"'"
write(*,'("}")')
end subroutine debug_op_matrix_t
end program test
The program was compiled with `ifort test.f90` and run as `./a.out`. In order to try to get slightly more information, I also compiled with `ifort -O0 -g -warn all -check all -debug all -traceback test.f90`, without any change in behavior. An example output is in the attachment, out1.txt
The crash occurs after initializing the `subspace` component with the empty string, and then printing out the data structure. The problem disappears when setting `op_subspace_l` to 10 instead of 5. It also works with other compilers, or other versions of ifort (I tried ifort 11). Is this a compiler bug?
Occasionally, the crash message changes. One message that was particularly concise was
goerz@mlhpc2:~> ./a.out
obs = {
subspace = ''
}
obs = {
a.out: malloc.c:2394: sysmalloc: Assertion `(old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)' failed.
Aborted (core dumped)