Reproducible Slicer crash on attempted tab completion, on Nightly 2020-01-08

Running the following code snippet in the python interactor (or a linked Jupyter notebook) and then typing “interp_f” and hitting the Tab key reproducibly crashes Slicer.

from scipy.interpolate import RegularGridInterpolator
import numpy as np
data_kji = np.ones((10,20,30)) #arrayFromVolume(volNode)
data_ijk = np.transpose(data_kji, axes=(2,1,0)) # reverse dimension order from kji to ijk
iLen,jLen,kLen = data_ijk.shape
iVals = list(range(iLen))
jVals = list(range(jLen))
kVals = list(range(kLen))
interp_from_ijk = RegularGridInterpolator((iVals, jVals, kVals), data_ijk)

If I don’t use Tab completion, I can use the interpolator just fine, e.g.

interp_from_ijk([[5,5,5]])

works as expected with no crash.

This crash occurs even after a clean Slicer start. It also occurs without being linked to a Jupyter kernel.

Interesting. I cannot reproduce this with latest Slicer Preview Release on Windows - auto-complete for interp_f works without any problem. Maybe you could start with a new Slicer installation, installing Python packages one by one and see which one introduces the crash.

I’ll try to remember to do this at some point in the future. At the moment, since there is an easy work-around, I am just going with that.

1 Like

I have encountered a problem like this again. I have a very simple module I am developing (called “AirwayLandmarks”) which has a qt.QTableWidget() as a GUI element. I had defined a convenience lambda at the Python interactor prompt:

w = lambda : slicer.modules.AirwayLandmarksWidget

I did this just to save a little typing after reloading the module as I was developing it. That way instead of typing slicer.modules.AirwayLandmarksWidget I could just type w().

The QtableWidget is stored in slicer.modules.AirwayLandmarksWidget.fhTable, which I can also access via w().fhTable. If I try to tab-complete something after this, i.e. something like
>>> w().fhTable.clearS
and hit the tab key, the normal autocomplete list appears with appropriate options

but if I select any of the options, Slicer crashes.

If I reopen Slicer, reopen the AirwayLandmarks module, and do the same thing without using the lambda, i.e.

>>> slicer.modules.AirwayLandmarksWidget.fhTable.clearS
and hit the tab key, I get the same options, but selecting one of them does not crash Slicer.

I’m currently running the Nightly 2020-04-07 release, but will probably update to a more recent nightly early next week.

Thanks for the follow-up. Can you share a minimal example module that reproduces the issue?

Using the extension wizard, I created a module with the default auto-created code, called AutoCompleteCrash. To the AutoCompleteCrash.py file I inserted the following 5 lines at line 81:

table = qt.QTableWidget()
table.setRowCount(5)
table.setColumnCount(3)
self.table = table
parametersFormLayout.addRow(self.table)

Then, after reloading the module, at the python interactor slicer.modules.AutoCompleteCrash.table.clearSelection() does not cause a crash, even when tab autocomplete is used partway through typing clearSelection(), but after
w = lambda : slicer.modules.AutoCompleteCrashWidget, then w().table.clearSel followed by pressing the tab key crashes Slicer and the window closes.

Here are the last few lines of the log file of a crashed session:

[INFO][Stream] 25.05.2020 08:11:25 (unknown:0) - ------------------------------
[INFO][Stream] 25.05.2020 08:11:25 (unknown:0) - Reloading module: AutoCompleteCrash
[INFO][Stream] 25.05.2020 08:11:25 (unknown:0) - ------------------------------
[INFO][Stream] 25.05.2020 08:11:25 (unknown:0) -
[INFO][Stream] 25.05.2020 08:11:25 (unknown:0) -
[INFO][Stream] 25.05.2020 08:11:25 (unknown:0) -
[DEBUG][Qt] 25.05.2020 08:11:57 (unknown:0) - Python console user input: slicer.modules.AutoCompleteCrashWidget.table.clearSelection()
[DEBUG][Qt] 25.05.2020 08:12:26 (unknown:0) - Python console user input: w = lambda : slicer.modules.AutoCompleteCrashWidget

I am running Slicer nightly 2020-04-07 on Windows 10.

Thank you for the more detailed information, it is very useful. Would you mind sharing your AutoCompleteCrash.py file(upload to https://gist.github.com/ and copy the link here)?

Here you go:

I just downloaded and installed the 2020-05-27 preview release, and I cannot reproduce this crash on the new release. I also can’t use the new release because it appears to not be compatible with extensions I rely on (SlicerJupyter, SegmentEditorExtraEffects, SlicerOpenCV), but at least this issue seems to have been resolved somehow, and I’ll look forward to when I can upgrade.

EDIT: It turns out the Extension Manager was incorrectly informing me that these extensions were not compatible, after a series of frustrating interactions with the Extension Manager (https://discourse.slicer.org/t/problematic-behavior-of-the-extension-manager/10986), it told me that actually these extensions ARE compatible with the version I just installed, and I was able to install them. I did not restart immediately, and when I reopened the Extension Manager, it again told me that none of the extensions were compatible. However, when I restarted Slicer, they were all installed, so I think things are good.

1 Like