CRPropa / CRPropa3

CRPropa is a public astrophysical simulation framework for propagating extraterrestrial ultra-high energy particles. https://crpropa.github.io/CRPropa3/
https://crpropa.desy.de
GNU General Public License v3.0
65 stars 66 forks source link

Segmentation fault with lens.transformModelVector #448

Closed ryohiguchi closed 4 months ago

ryohiguchi commented 7 months ago

I'm trying the same code as in the documentation page: https://crpropa.github.io/CRPropa3/pages/example_notebooks/galactic_lensing/lensing_maps.v4.html

The example code works until the plot of unlensed map, but transformModelVector command outputs: zsh: segmentation fault

The information of my current system is as follows:

I also read the similar issue (https://github.com/CRPropa/CRPropa3/issues/397) and tested changing some versions of python & swig and also CRPropa 3.1.7, but the results are same.

lukasmerten commented 7 months ago

Hi @ryohiguchi This is, as you have seen, a known problem. But to my knowledge nobody is currently working on it. In case you you find a fix we would be happy to include it.

ryohiguchi commented 7 months ago

It was successful when I change the numpy version==1.18.0 The problem seems to be that they are calling a deprecated numpy function PyArray_GetArrayParamsFromObject https://numpy.org/devdocs/release/1.19.0-notes.html#deprecation-of-probably-unused-c-api-functions

lukasmerten commented 4 months ago

@ryohiguchi can you pleas check if #466 fixed this issue. Please reopen if the problem persists.

potassium-chloride commented 4 months ago

I have the same issue.

I checked new version and the problem still exists:

System Information:

I've checked difference of last pull request and code of python/4_lens.i was a little bit refactored but its logic is absolutely same.

I've made some tests. The segmentation fault happens on lens.transformModelVector(outputMap, rigidity * crpropa.EeV) and I think that @ryohiguchi is right. Unfortunately, I don't understand SWIG NumPy API and can't help you today. I've tried removing this line and replacing double *dataPointer = (double*) PyArray_DATA(arr); to simple double *dataPointer = (double*) PyArray_DATA((PyArrayObject *)arr);. It raises another behavior: transformModelVector doesn't crush, but object outputMap will be broken and cannot be read from Python. I don't understand how these structures work.