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

User-defined function in DiagScreen gives a SegFault #27

Closed
lesnat opened this issue Nov 9, 2017 · 5 comments
Closed

User-defined function in DiagScreen gives a SegFault #27

lesnat opened this issue Nov 9, 2017 · 5 comments

Comments

@lesnat
Copy link
Contributor

lesnat commented Nov 9, 2017

Hi,
I'm trying to use user-defined function in DiagScreen, but it gives me a SegFault.
Namelist (for the test) :

def function(particles):
    return particles.px

DiagScreen(
    shape = "plane",
    point = [11.*l0,0.],
    vector = [1.,0.],
    direction = "forward",
    deposited_quantity = "weight",
    species = ["e"],
    every = Tsim/2,
    axes = [[function, 0. , 8. , 100]]
)

Error :

 Time-Loop started: number of time-steps n_time = 2250
 --------------------------------------------------------------------------------
    timestep       sim time   cpu time [s]   (    diff [s] )
[pc-newAV:17978] *** Process received signal ***
[pc-newAV:17978] Signal: Segmentation fault (11)
[pc-newAV:17978] Signal code: Address not mapped (1)
[pc-newAV:17978] Failing at address: 0x48
[pc-newAV:17978] [ 0] /lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7f9d9ccef390]
[pc-newAV:17978] [ 1] /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyErr_Occurred+0xa)[0x7f9d9d0e321a]
[pc-newAV:17978] [ 2] /usr/lib/python2.7/dist-packages/numpy/core/multiarray.x86_64-linux-gnu.so(+0x45a92)[0x7f9d9141aa92]
[pc-newAV:17978] [ 3] /usr/lib/python2.7/dist-packages/numpy/core/multiarray.x86_64-linux-gnu.so(+0x2041e)[0x7f9d913f541e]
[pc-newAV:17978] [ 4] /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(+0x15d747)[0x7f9d9d058747]
[pc-newAV:17978] [ 5] /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyDict_SetItem+0x7b)[0x7f9d9d05cecb]
[pc-newAV:17978] [ 6] /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(_PyObject_GenericSetAttrWithDict+0xb8)[0x7f9d9d096838]
[pc-newAV:17978] [ 7] /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyObject_SetAttr+0x87)[0x7f9d9d096d67]
[pc-newAV:17978] [ 8] /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0(PyObject_SetAttrString+0x3c)[0x7f9d9d09702c]
[pc-newAV:17978] [ 9] /home/users1/esnault/Installation/smilei-v3.3/./smilei(_ZN12ParticleData3setEP9Particles+0xb0)[0x45e800]
[pc-newAV:17978] [10] /home/users1/esnault/Installation/smilei-v3.3/./smilei(_ZN27HistogramAxis_user_function8digitizeEP7SpeciesRSt6vectorIdSaIdEERS2_IiSaIiEEjP9SimWindow+0x3e)[0x45f05e]
[pc-newAV:17978] [11] /home/users1/esnault/Installation/smilei-v3.3/./smilei(_ZN9Histogram8digitizeEP7SpeciesRSt6vectorIdSaIdEERS2_IiSaIiEEP9SimWindow+0xd3)[0x488053]
[pc-newAV:17978] [12] /home/users1/esnault/Installation/smilei-v3.3/./smilei(_ZN16DiagnosticScreen3runEP5PatchiP9SimWindow+0x687)[0x450d27]
[pc-newAV:17978] [13] /home/users1/esnault/Installation/smilei-v3.3/./smilei(_ZN11VectorPatch11runAllDiagsER6ParamsP9SmileiMPIjR6TimersP9SimWindow+0x17a)[0x50460a]
[pc-newAV:17978] [14] /home/users1/esnault/Installation/smilei-v3.3/./smilei[0x551b58]
[pc-newAV:17978] [15] /usr/lib/x86_64-linux-gnu/libgomp.so.1(+0xf43e)[0x7f9d9bf3a43e]
[pc-newAV:17978] [16] /lib/x86_64-linux-gnu/libpthread.so.0(+0x76ba)[0x7f9d9cce56ba]
[pc-newAV:17978] [17] /lib/x86_64-linux-gnu/libc.so.6(clone+0x6d)[0x7f9d9ba523dd]
[pc-newAV:17978] *** End of error message ***
./launcher : ligne 11 : 17978 Erreur de segmentation  (core dumped) ~/Installation/smilei-v3.3/./smilei namelist.py

I've also the same error with the user-defined function with deposited_quantity on DiagScreen

Local installation with :
Smilei version : 3.3
openmpi version : 1.10.2
hdf5 version : 1.8.16

Léo.

@beck-llr
Copy link
Contributor

beck-llr commented Nov 9, 2017

Hi Leo
I believe you have to pass your "function" to the deposited_quantity argument, not to the axes. Axes refer to the axes of the histogram you want to build.

@mccoys
Copy link
Contributor

mccoys commented Nov 9, 2017

In fact, axes should work as well. Let me have a look

@mccoys
Copy link
Contributor

mccoys commented Nov 9, 2017

I think I have an idea. Python might get closed before smilei starts the loop. There is a dirty workaround to make it work. Use any custom time profile somewhere in the namelist, and it will keep python alive.

For instance, add an empty laser:

Laser( space_time_envelope = (lambda t: 0) )

(or whatever works in your simulation).

If this is the problem, I will correct it tomorrow.

@lesnat
Copy link
Contributor Author

lesnat commented Nov 10, 2017

With adding an empty laser it is now working, thank you !

@mccoys
Copy link
Contributor

mccoys commented Nov 10, 2017

The latest commit should have fixed your problem, without need of an empty laser.

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

3 participants