Closed cphyc closed 3 years ago
Further investigation:
g++-5 (GCC) 5.5.0
the segfault disappearscc1plus: warning: function returns address of local variable [-Wreturn-local-addr]
In file included from src/tools/numerics/fourier.hpp:15,
from src/ic.hpp:15,
from src/main.cpp:9:
[...]/genetIC/genetIC/src/simulation/field/field.hpp:386:46: note: declared here
386 | return cache::cachedInterpolators.get(key).get();
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
[...]/genetIC/genetIC/src/simulation/field/field.hpp:382:12: note: declared here
382 | auto result = cache::cachedInterpolators.get(key);
| ^~~~~~
Ahah, that's really useful. Yes I begin to see the problem.
The test
test_01c_zoom_grid
fails with a segfault.Configuration
-g -O2
Note that with the same configuration and
-O1
or-O0
, the tests all seem to work.Steps to reproduce
Compile the code and run the parameter file
tests/test_01c_zoom_grid/paramfile.txt
.Debugging
When debugging, it seems the issue comes the variable
valsForInterpolation
being unallocated before being used. The variable is created here https://github.com/pynbody/genetIC/blob/6683d294dbaeeb788d5302092594cfe4bb01d242/genetIC/src/simulation/field/field.hpp#L395 The line where the segfault is reported is somewhere around here (not exact location because of the optimization flags). https://github.com/pynbody/genetIC/blob/0b75bf8cf5df71574a1939dd815dae1723900365/genetIC/src/simulation/field/field.hpp#L298-L299