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

Crash when reusing PyQSTEM object with different number of slices. #19

Open
schiotz opened this issue Jun 18, 2020 · 3 comments
Open

Crash when reusing PyQSTEM object with different number of slices. #19

schiotz opened this issue Jun 18, 2020 · 3 comments

Comments

@schiotz
Copy link
Contributor

schiotz commented Jun 18, 2020

Hi Jacob,

PyQSTEM sometimes crashes when you reuse the same object with a different number of slices. Using a new pyqstem object in each iteration instead leads to a memory leak.

The attached script shows the problem. On a Mac, it gives the error

Corrupt value: 0x3f0278d13f0278d1
Python(6133,0x1136c5dc0) malloc: *** set a breakpoint in malloc_error_break to debug
Abort trap: 6

On linux, it just gives a Segmentation fault (core dumped). It is not 100% reproducible, the attached script crashes every second time or so.

@schiotz
Copy link
Contributor Author

schiotz commented Jun 18, 2020

import numpy as np
from pyqstem import PyQSTEM
import ase.build


qstem=PyQSTEM('TEM')
rng = np.random.default_rng()

for i in range(10):
    atoms = ase.build.bulk('Au', orthorhombic=True).repeat((2,2,2))
    atoms.center(vacuum=10*rng.random(), axis=2)

    wave_size=(int(atoms.get_cell()[0,0]*10),int(atoms.get_cell()[1,1]*10))
    print("Setting atoms")
    qstem.set_atoms(atoms)
    print("Building wave:", wave_size)
    qstem.build_wave('plane', 300, wave_size)
    slices = int(atoms.get_cell()[2,2]*2)
    print("Building potential: slices =", slices)
    qstem.build_potential(slices)
    print("Running multislice")
    qstem.run()

(Sorry, cannot attach a .py file).

@jacobjma
Copy link
Owner

Hi Jakob,

PyQSTEM has quite a few issues. I will probably not have time to fix them, as I will release its replacement at the MM20 meeting. I have spent quite a bit of time on the new package, and it should be better in every possible way.

@schiotz
Copy link
Contributor Author

schiotz commented Aug 11, 2020

Hi Jacob,

This makes sense. I saw your M&M2020 talk, and I am looking forward to trying it out!

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

2 participants