hannorein/rebound

Segmentation fault with latest Rebound version when accessing orbit of a particle

Anit5577 opened this issue · 5 comments

Environment
Which version of REBOUND are you using and on what operating system?

  • REBOUND Version: [4.0.3]
  • API interface: [Python]
  • Operating System (including version): [Linux]

Describe the bug
I have just updated to the latest REBOUND version and changed the names of different functions in my analysis script (e.g. SimulationArchive to Simulationarchive) to the new names. However, when I run my script, I now get a segmentation fault every time:

Fatal Python error: Segmentation fault

Main thread:
Current thread 0x00007f83901921c0 (most recent call first):
File "/home/cschoett/.local/lib/python3.10/site-packages/rebound/particle.py", line 460 in orbit
File "/home/cschoett/Documents/Kepler_dichotomy_rebound/Rebound_batch_analysis_full_incl.py", line 563 in <----
File "/home/cschoett/.local/lib/python3.10/site-packages/spyder_kernels/py3compat.py", line 356 in compat_exec
File "/home/cschoett/.local/lib/python3.10/site-packages/spyder_kernels/customize/spydercustomize.py", line 469 in exec_code
File "/home/cschoett/.local/lib/python3.10/site-packages/spyder_kernels/customize/spydercustomize.py", line 736 in _exec_cell
File "/home/cschoett/.local/lib/python3.10/site-packages/spyder_kernels/customize/spydercustomize.py", line 685 in runcell
File "/tmp/ipykernel_46322/1087412396.py", line 1 in <cell line: 1>

In the location above <---- in my own script, I use a hash to access the semi-major axis of a particle in my simulations. This segmentation fault does not occur at the same point in the script every time I run it. Sometimes, it occurs when I access the inclination of a different planet. The other script references are the same, though. This worked find in the past after updating REBOUND and has now failed.

sim_list[n][x].particles[h(5)].orbit(primary=sim_list[n][x].particles[centre_star]).a

np.degrees(sim_list[n][x].particles[h(4)].orbit(primary=sim_list[n][x].particles[centre_star]).inc)

This is hard to debug without seeing more of your code (ideally something short I can run myself to reproduce the issue). From what I see here, it looks like the particle for which you calculate the orbit has an invalid pointer to a simulation it is supposed to be in (each particle has a pointer so it knows in which simulation it is in). So maybe you deallocated a simulation at some point by accident?

Just putting something together for you to reproduce this issue. In the meantime, I downgraded my Rebound version to 3.26.0, where this is not happening when analysing my data. Anything more recent than that causes a segmentation fault.

It seems that the issue I am having is connected with analysing simulations set up/run with an older version Rebound (e.g. 3.26.0) when my analysis code runs in the latest version. I now have a few simulations that are created and run in the latest version 4.3.1 and I no longer experience a segmentation fault when being analysed while running the latest version.

In principle SimulationArchives should be compatible across different versions. But I would recommend to save/load simulations with the same version. I just can't test all possible combinations.

Completely agree, thanks.