heap-buffer-overflow when constructing the t->scale-factor table in cosmology module
When running with cosmology on and the address sanitizer,
./configure --enable-sanitizer
../swift -s -c -G -t 8 zeldovichPancake.yml
we get the following crash:
[00000.0] main: Reading runtime parameters from file 'zeldovichPancake.yml'
=================================================================
==17673==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6320000487f8 at pc 0x0000004b82bf bp 0x7ffde6d950a0 sp 0x7ffde6d95090
READ of size 8 at 0x6320000487f8 thread T0
#0 0x4b82be in cosmology_init_tables (/data1/matthieu/SWIFT/master/swiftsim/examples/swift+0x4b82be)
#1 0x4b88bd in cosmology_init (/data1/matthieu/SWIFT/master/swiftsim/examples/swift+0x4b88bd)
#2 0x4053ca in main (/data1/matthieu/SWIFT/master/swiftsim/examples/swift+0x4053ca)
#3 0x7f1650013f29 in __libc_start_main (/lib64/libc.so.6+0x20f29)
#4 0x408bb9 in _start (/data1/matthieu/SWIFT/master/swiftsim/examples/swift+0x408bb9)
0x6320000487f8 is located 8 bytes to the left of 80000-byte region [0x632000048800,0x63200005c080)
allocated by thread T0 here:
#0 0x7f165265f850 in malloc (/lib64/libasan.so.4+0xde850)
#1 0x4b6f69 in cosmology_init_tables (/data1/matthieu/SWIFT/master/swiftsim/examples/swift+0x4b6f69)
#2 0x4b88bd in cosmology_init (/data1/matthieu/SWIFT/master/swiftsim/examples/swift+0x4b88bd)
#3 0x4053ca in main (/data1/matthieu/SWIFT/master/swiftsim/examples/swift+0x4053ca)
#4 0x7f1650013f29 in __libc_start_main (/lib64/libc.so.6+0x20f29)
It looks like the loop does something incorrect when i_prev
is 0 so probably in the first iteration.