PropertyGridManager causes segmentation fault

Hello,

I do have a strange behavior (most likely a misunderstanding about how to use it correctly) when using the propertygrid manager.
Some background infos first.
I do have an working app built with wxPython 3.0.2.0 GTK (classic) which uses the propertygridmanager class
and the way how I implemented it without a problem.
Now I 'm in the process of converting it to use wxPython 4.0.0a1 and I do get a segmentation fault when running the app.

I tracked down that the following code is causing this

    self.propview = wxpg.PropertyGridManager(self,
                                             id=wx.ID_ANY,
                                             pos=wx.DefaultPosition,
                                             size=wx.DefaultSize,
                                             style=wxpg.PG_BOLD_MODIFIED |
                                                   wxpg.PG_SPLITTER_AUTO_CENTER |
                                                   wxpg.PG_TOOLBAR |
                                                   wxpg.PG_DESCRIPTION |
                                                   wxpg.PGMAN_DEFAULT_STYLE)

``

Trying to track it further down I created a standalone app using the same code and here the code works but with different results.

Using classic results in this http://i.imgur.com/5AMenrN.png
but using version 4 results in this http://i.imgur.com/CeiM5Mr.png

But NO seg fault.

Attached the code which I use.

What I’m looking for is how to track down why my app does something which causes this seg fault.
Any ideas what I could do?
Note, I’m using linux ubuntu.

Cheers
Claudia

init.py|attachment (7.08 KB)

Does the related demo work for you?
I'm on Windows and PropertyGridManager does not work for me either (Python 3.5 in 32 or 64 bit). I get crashes as soon as I run the related demo or when I try to use it from another program.

Regards,

Dietmar

···

On 18.04.17 23:58, Claudia Frank wrote:

What I'm looking for is how to track down why my app does something which causes this seg fault.
Any ideas what I could do?

It seems that PropertyGridManager is indeed not working on several platforms (up to at least revision 4.0.0.a2).
See discussion on bug #200.

Regards,

Dietmar

···

On 19.04.17 21:11, Dietmar Schwertberger wrote:

On 18.04.17 23:58, Claudia Frank wrote:

What I'm looking for is how to track down why my app does something which causes this seg fault.
Any ideas what I could do?

Does the related demo work for you?
I'm on Windows and PropertyGridManager does not work for me either (Python 3.5 in 32 or 64 bit). I get crashes as soon as I run the related demo or when I try to use it from another program.

Dietmar, what tracker are you looking on for that bug #200? I only see five on github (Issues · wxWidgets/wxPython-Classic · GitHub) and the wxWidgets tracker is in the tens of thousands now…

I’ve been fighting the Grid widgets in Phoenix for over a year, there are lots of problems. When I try to grab cells, it sometimes works, but more often it silently quits, or seg faults, or throws wxAssertions about ref counts, or recurses forever…

I haven’t put in the effort to write a short snippet to reproduce it (I’m seeing this in a 10-year-old piece of code that’s got 70k lines devoted to the gui, so it’s a nightmare to debug this stuff).

ERROR: Traceback for wxAssertionError:

lm/gui/table.py 393 in OnSize:

0392 “”" Auto-size rightmost column to fill grid area. “”"

0393* self.ResizeLastColumn()

0394 event.Skip()

lm/gui/table.py 401 in ResizeLastColumn:

0400 if lastCol >= 0:

0401* rect = self.CellToRect(0, lastCol)

0402 w1 = self.GetClientSize()[0]

wxAssertionError: C++ assertion “uiIndex < m_nCount” failed at c:/PROJECTS/buildbots/win7-py27/dist-win64-py27/Phoenix/ext/wxWidgets/include/wx/dynarray.h(841) in wxBaseArrayInt::Item():

or

Traceback (most recent call last):

File “lm/gui/table.py”, line 1034, in Draw

self.setColorsAndFont(grid, attr, dc, rect, row, col, isSelected)

File “lm/gui/table.py”, line 1104, in setColorsAndFont

elif grid.IsReadOnlyCell(row, col):

File “lm/gui/propertyEditor.py”, line 403, in IsReadOnlyCell

property = self.GetProperty(row, col)

RuntimeError: maximum recursion depth exceeded

Eric

···

On Wednesday, April 19, 2017 at 2:18:02 PM UTC-7, Dietmar Schwertberger wrote:

On 19.04.17 21:11, Dietmar Schwertberger wrote:

On 18.04.17 23:58, Claudia Frank wrote:

What I’m looking for is how to track down why my app does something
which causes this seg fault.

Any ideas what I could do?

Does the related demo work for you?

I’m on Windows and PropertyGridManager does not work for me either
(Python 3.5 in 32 or 64 bit). I get crashes as soon as I run the
related demo or when I try to use it from another program.
It seems that PropertyGridManager is indeed not working on several
platforms (up to at least revision 4.0.0.a2).

See discussion on bug #200.

Regards,

Dietmar

Dietmar, what tracker are you looking on for that bug #200? I only see five on github (Issues · wxWidgets/wxPython-Classic · GitHub) and the wxWidgets tracker is in the tens of thousands now...

Phoenix bugs are here: Issues · wxWidgets/Phoenix · GitHub
The referenced #200 is at PropertyGrid crash · Issue #200 · wxWidgets/Phoenix · GitHub

I've been fighting the Grid widgets in Phoenix for over a year, there are lots of problems. When I try to grab cells, it sometimes works, but more often it silently quits, or seg faults, or throws wxAssertions about ref counts, or recurses forever...

The grid in Phoenix is more picky about GridCellAttr references than with previous revisions.
In the beginning I had problems when the reference to cell attributes were deleted.
If you have a look at the wxPython demos, the attributes are stored forever.
If you are using the GetAttr callback to provide cell attributes dynamically or if you set the attributes of cells, then be sure not to delete the reference to the attribute instances too early. If you re-use an instance, call the IncRef method.
Actually, I think with my code now I'm keeping all calculated attributes in a dictionary. When a certain combination of e.g. color and alignment is required again, in GetAttr I call att.IncRef() and return the old attribute. I don't delete them any more.

Regards,

Dietmar

···

On 19.04.17 23:54, efahl wrote:

Hello Dietmar

Does the related demo work for you?

NO if using demo.py

(2.7.12) chalet@charly:/disc3/repos/phoenix/demo$ python demo.py

** (demo.py:12359): CRITICAL **: murrine_style_draw_box_gap: assertion ‘height >= -1’ failed

** (demo.py:12359): CRITICAL **: murrine_style_draw_box_gap: assertion ‘height >= -1’ failed

** (demo.py:12359): CRITICAL **: murrine_style_draw_box_gap: assertion ‘height >= -1’ failed
Speicherzugriffsfehler

but YES,if I run the demo standalone, meaning calling python run.py PropertyGrid.py.
I do have to ack some assertions

(2.7.12) chalet@charly:/disc3/repos/phoenix/demo$ python run.py PropertyGrid.py
Python 2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609]
wx.version: 4.0.0a1 gtk2 (phoenix)
/tmp/pip-build-G2gBWx/wxPython/ext/wxWidgets/src/common/variant.cpp(837):
assert “Assert failure” failed in GetChar(): Could not convert to a char
/tmp/pip-build-G2gBWx/wxPython/ext/wxWidgets/src/common/variant.cpp(837):
assert “Assert failure” failed in GetChar(): Could not convert to a char
/tmp/pip-build-G2gBWx/wxPython/ext/wxWidgets/src/common/variant.cpp(837):
assert “Assert failure” failed in GetChar(): Could not convert to a char

but at the end I do have the gui which can be seen here http://i.imgur.com/16LWkNp.png

Cheers
Claudia

Yes, that's also what Robin found: standalone is OK, embedded in demo.py crashes.
So you should have a look at bug #200. When it gets closed, you should try your program again.

Regards,

Dietmar

···

On 20.04.17 01:00, Claudia Frank wrote:

but YES,if I run the demo standalone, meaning calling python run.py PropertyGrid.py.
I do have to ack some assertions

Thank you very much - I will keep an eye on it.

Cheers
Claudia

Can confirm that latest build (‘4.0.0a3 gtk2 (phoenix)’) solved the issue.

Thank you very much
Claudia