|
Bugzilla – Full Text Bug Listing |
| Summary: | python-yui crashes with segfault when using TreeItem widget | ||
|---|---|---|---|
| Product: | [openSUSE] openSUSE 11.0 | Reporter: | Pranav Senthilnathan <pirhoalpha> |
| Component: | YaST2 | Assignee: | Klaus Kämpf <kkaempf> |
| Status: | RESOLVED FIXED | QA Contact: | Jiri Srain <jsrain> |
| Severity: | Normal | ||
| Priority: | P5 - None | ||
| Version: | Final | ||
| Target Milestone: | Future/Later | ||
| Hardware: | i586 | ||
| OS: | SLES 11 | ||
| Whiteboard: | |||
| Found By: | --- | Services Priority: | |
| Business Priority: | Blocker: | --- | |
| Marketing QA Status: | --- | IT Deployment: | --- |
The problem is that you cannot create TreeItems stand-alone. They need to be embedded into a dialog and a vbox/hbox: factory = yui.YUI.widgetFactory() dialog = factory.createPopupDialog() vbox = factory.createVBox( dialog ) item = factory.createTree(vbox, "root") event = dialog.waitForEvent() dialog.destroy() This examples runs without crash. My knowledge about libyui trees is too limited to complete the example :-( Bubli, any hints how to properly add items to the tree ? The following code creates a tree with 2 items (top- and 1st level)
factory = yui.YUI.widgetFactory()
dialog = factory.createPopupDialog()
item1 = yui.YTreeItem("hello")
item2 = yui.YTreeItem( item1, "world")
vbox = factory.createVBox( dialog )
tree = factory.createTree( vbox, "Hello, World!" )
// add top level item only, its children will be added automatically
tree.addItem(item1)
factory.createPushButton( vbox, "&OK" )
event = dialog.waitForEvent()
dialog.destroy()
For some reason, the tree items are visible only in ncurses (GUI shows an empty box). Nevertheless, segfault on dialog close occurs in both cases
Hm, tried to obtain some backtrace, but this is all I managed to get :( #0 0x00000031 in ?? () #1 0xc381fffd in ?? () Backtrace stopped: previous frame inner to this frame (corrupt stack?) See https://bugzilla.novell.com/show_bug.cgi?id=427372#c16 Its a double-free. The addItem call transfers the 'memory ownership' to 'tree' but swig thinks it still needs to de-allocated the created item. This probably needs fixing in libyui Uhm, no, fixing in libyui (adding _disown to function declarations) doesn't help :-( I fear the problem is the usage of the YTreeItem constructor. When using it with a parent, "The parent assumes ownership of this item" (citation from YTreeItem.h). I was wrong in comment #5. Adding the _disown does the trick but must be done with the correct parameter name. This fixes the crash: --- YTreeItem.h (revision 62165) +++ YTreeItem.h (working copy) @@ -117,7 +117,7 @@ * automatically add themselves to their parent, so applications will * normally not have to call this function. **/ - virtual void addChild( YItem * child ); + virtual void addChild( YItem * item_disown ); Committed to svn as rev 62170 Note that this only prevents the crash. It does not fix Qt to properly display the tree. The example works fine in Ncurses though. Want to push an update out ? ;-) For 11.3/Factory - sure For SLE11[-SP1] - we'd have to ask maintenance team for approval then python-yui is on the SLE11 SDK and thus not maintained. Closed as fixed for 11.3 |
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.6) Gecko/2009012700 SUSE/3.0.6-1.14 Firefox/3.0.6 When I create TreeItems, the program runs fine until the end, where is crashes with a segfault. I am using python 2.6. The yast development team thought this was most likely a dangling pointer issue. Even this simple code crashes: import sys sys.path.insert(0, '/usr/src/packages/BUILD/libyui-bindings-0.1.0/build/swig/python/') import yui item = yui.YTreeItem("root") item2 = yui.YTreeItem(item, "Desktop") Every other widget that I tried worked though. Reproducible: Always Steps to Reproduce: 1. Run following python code (change sys.path to where python bindings are): import sys sys.path.insert(0, '/usr/src/packages/BUILD/libyui-bindings-0.1.0/build/swig/python/') import yui item = yui.YTreeItem("root") item2 = yui.YTreeItem(item, "Desktop") Actual Results: segmentation fault Expected Results: error free exit Yast developers said this is probably a dangling pointer issue or at least deals with memory ownership issues.