Crash or timeout / deadlock when assigning np-arrays to plots

Issue #75 resolved
M. Gronle created an issue
import numpy as np 
i,h=plot(np.zeros([200,200])) 
h['source']=np.zeros([200,200] )
h['source']=np.zeros([200,200])

The last line forces a crash or sometimes a timeout exception.

The reason is probably the acquisition of the python GIL in baseObjectDeleterDataObject (see commit 556def4)

Comments (4)

  1. M. Gronle reporter

    The problem is in baseObjectDeleterDataObject in case, that a dataObject, whose source is a python variable, is lastly deleted by a plot. Then the baseObjectDeleterDataObject is called from the GUI thread, however this deletion was firstly initialized by a Python method. Hence, python holds the GIL, waits for the plot to finish the assignment of the new np.array, but the plot tries to delete the previous dataObject, which requires the GIL itself.

    Possible solution: If the GIL is not locked by the thread, calling baseObjectDeleterDataObject, try to call the Py_DECREF in a background worker thread.

  2. itobiege

    fixes issue #75: prevents a python GIL deadlock, if a np.array is converted to a dataObject and the dataObject is passed to a plot. If the plot then is forced by python to apply another dataObject, the old dataObject is deleted and its base-object (the np.array) should then be deleted, too. However, Python is currently blocked such that the base object cannot be deleted, since the GIL is not free. In this case, the deletion is now put into a concurrent worker thread to be executed when Python is ready again!

    → <<cset 911851a1c94d>>

  3. Log in to comment