pynbody / genetIC

The GM initial conditions generator
GNU General Public License v3.0
21 stars 8 forks source link

Segmentation fault with g++ and optimization flags #82

Closed cphyc closed 3 years ago

cphyc commented 3 years ago

The test test_01c_zoom_grid fails with a segfault.

Configuration

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

cphyc commented 3 years ago

Further investigation:

apontzen commented 3 years ago

Ahah, that's really useful. Yes I begin to see the problem.