Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segfault when repeatedly redefining a spinw object with temporary numpy arrays #19

Closed
mducle opened this issue Jun 19, 2023 · 0 comments

Comments

@mducle
Copy link
Member

mducle commented Jun 19, 2023

This code will cause a segfault if run repeatedly:

from pyspinw import Matlab
import numpy as np
m = Matlab()

lat = [5.408, 5.4599, 19.266]
swo = m.spinw()
swo.genlattice('lat_const', np.array(lat) * np.array([2, 2, 1]), 'angled', [90, 90, 90], 'spgr', 'x,y+1/2,-z')
swo.addatom('r', [0, 0, 0], 'label', 'MCu2')

If the second last line is changed to:

swo.genlattice('lat_const', [5.408*2, 5.4599*2, 19.266], 'angled', [90, 90, 90], 'spgr', 'x,y+1/2,-z');

the segfault does not occur. The segfault also does not occur for a simple pass-through, e.g.

from pyspinw import Matlab
import numpy as np
m = Matlab()

iden = m.str2func('@(x)x')
lat = [5.408, 5.4599, 19.266]
x = m.feval(iden, np.array(lat) * np.array([2, 2, 1]))
print(x)
mducle added a commit that referenced this issue Oct 2, 2023
* Change tuple conversion to always give cell #18

* Workaround for segfault on multiple reuse of wrap np array #19

* Update tests

* Fix nargout bug; now defaults to nargout=0 spinw#147

* Update CITATION.cff, CHANGELOG.md

* Fix get_nlhs() function for nested calls

* Restore get_nlhs from disassembly

* Fix heap error in converter in call_python

* Move py fun wrapper to type_conv from libpymcr main

* Fix euphonic/tobyfit errors

Change call_python to use global dict
Update to work on Python 3.11
Add setdlopenflags(DEEPBIND) for Linux
@mducle mducle closed this as completed Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant