-
Notifications
You must be signed in to change notification settings - Fork 95
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
Table in a dialog segfaults under wx, EPD 7 #2
Comments
On Wed, Jun 15, 2011 at 4:04 PM, jdmarch
This looks very similar to an issue that I was encountering recently, (1) Run the script from a Terminal prompt. ("python jmarch.py") Mark |
Hmm. Doubling up the IncRef calls you mention doesn't work for me, though, so maybe I'm seeing a different issue. |
To clarify: I just switched my code to TabularEditor, mentioned Corran's IncRef suggestion as a possible diagnostic lead, but didn't try it myself yet. |
Some progress: the patch below (which is definitely an ugly workaround rather than a committable fix) fixes the BusError on my machine. Jonathan, do you have a second to see if this also fixes your issue? Basically, it seems as though something's trying to access the grid cell elements after the TableEditor has been disposed of. The hack below works by pretending that the number of rows and the number of columns are both zero if the TableModel .editor attribute has been set to None. This fixes the BusError for me. The right fix would clearly be to understand why Table elements are still being accessed after the editor has been disposed of, and to stop that happening, but that requires more wx and traitsui knowledge than I currently possess (though I'm working on it). Could Bryce maybe shed some light on what's wrong here?
|
Yes, your workaround works around my issue in Ubuntu. No time to test OSX right now. Nice hack. |
Bryce emailed: """ |
With the faulthandler code commented out, I get a "Bus error" in OS X 10.5.8 and ETS trunk with following sequence:
With Mark's patch, I do not get the bus error. |
Mark, absent a real fix, I think your patch belongs in master - prominently marked as temporary, of course ;) |
I've been reviewing this. Tried the heap browser but didn't get much usable from that. One breakthrough: the segfault I was seeing was almost, but not quite, 100% reproducible. I've think I've just figured out the 'almost' part: for me, the segfault is reliably caused by: (1) editing one of the rows of the table, then (2) hovering over a different row before closing the editor. This solves the puzzle of why I was seeing this only when clicking on the second row of the table---my mouse pointer naturally passed over the first row on the way to the close button! |
Okay, I'm out of time on this for now. Some observations for whoever next has a chance to pick it up again:
The key part that I still don't understand is why the final GetAttr call occurs after the _GridTableBase.dispose method gets called, or how to fix this. I suspect that either (1) a rearrangement of the cleanup code, or (2) a suitable use of invoke_later might be able to deal with this. |
Having said that I was out of time, I couldn't resist acting on the hunch that a well-placed 'do_later' (which is what I meant when I mistakenly wrote 'invoke_later' above) might solve this problem. And indeed, the following patch seems to fix things.
|
Fixed in the PyFace repository: |
Hmm. That 'fix' proved a little too hasty. It worked for a standalone TableEditor ui, but not for a TableEditor window popped up from another UI component---that gave a different segfault, apparently originating from the DecRef call in trait_grid_cell_adapter.py. I'd reopen this, except that this does appear to be a pyface issue at heart rather than a Traits UI issue. So I'll open an issue on the pyface tracker. |
Opened Pyface issue: |
The code below segfaults in Ubuntu 10.04 and Mac OSX 10.6 after several iterations of: click button to open table dialog, edit table, close table dialog. Not tested in Windows. The number of iterations before segfault varies depending on OS, which TableEditor options are set, prior state of the terminal session,.... i.e. presumably depending on the state of memory. Under Ubuntu, a faulthandler stack dump shows that the segfault occurs when wx is disposing of a panel.
Corran suspects unresolved deallocation bugs in TableEditor with wx, due to inaccurate manual reference counting of wx's Attr objects, and advises that a leaky workaround can be to double up one or both of the IncRef (increment reference) calls in method _GridTableBase.GetAttr in module traitsbackendwx/enthought/pyface/ui/wx/grid/grid.py.
Another workaround can be to use TabularEditor.
The text was updated successfully, but these errors were encountered: