Bug 452920 - Segmentation Fault when working adding Widget into Grid
Segmentation Fault when working adding Widget into Grid
Status: CLOSED NEXTRELEASE
Product: Fedora
Classification: Fedora
Component: newt (Show other bugs)
rawhide
i386 Linux
low Severity medium
: ---
: ---
Assigned To: Miroslav Lichvar
Fedora Extras Quality Assurance
http://www.wanware.com/tsgdocs/snack....
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2008-06-25 17:15 EDT by Greg Swift
Modified: 2008-09-10 03:05 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2008-07-30 09:29:59 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Greg Swift 2008-06-25 17:15:53 EDT
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9) Gecko/2008052912 Firefox/3.0

Description of problem:
I found a tutorial about using Newt in Python.  The first example under Forms and Grids segfaults. If I change their use of Widget to any of the classes based on Widget it seems to work fine.  I realize that this may just mean that you should never use Widget directly, but it should handle it without a segfault, IMHO.

Version-Release number of selected component (if applicable):
newt-python-0.52.9-1.fc9

How reproducible:
Always


Steps to Reproduce:
1. Run this script (built my stripping down the example code at listed URL):

#!/usr/bin/env python

from snack import *

s = SnackScreen()
g = Grid(1,1)
w = Widget()
g.setField(w,0,0)
s.gridWrappedWindow(g, "title")
s.popWindow()
s.finish()

Actual Results:
Segmentation Fault

Expected Results:
Nothing special if anything, but at the very least an exception being raised based on invalid object.

Additional info:
I've tried this on the following rpms:

newt-python-0.52.7-4.fc8.i386
newt-python-0.52.9-1.fc9.i386
Comment 1 Miroslav Lichvar 2008-06-26 11:14:35 EDT
I'm not sure the example has ever worked. Widget just provides the setCallback
function and isn't supposed to be used as a real widget.

Any suggestions where the exception should be raised? Checking in all functions
if w == None wouldn't be very nice.
Comment 2 Greg Swift 2008-06-26 11:45:33 EDT
Okay.. I'll concede that checking that in every function is not nice.  After
your response and having browsed through the source would these 2 assumptions be
true:

1: You shouldn't be using Widget directly, ever?
2: Whenever inheriting Widget you should override the __init__ method

If so You could always do this:

class Widget:
    """Base class for NEWT toolkit - Do not use directly

    methods:

     - Widget(self)
     - setCallback(self, obj, data = None) :
          The callback for when object activated.
          data is passed to obj.
    """
    def setCallback(self, obj, data = None):
        if data:
            self.w.setCallback(obj, data)
        else:
            self.w.setCallback(obj)

    def __init__(self):
        raise NotImplementedError

This was per the definition located at Python's Module Exception page[1], which
states:
"exception NotImplementedError
    This exception is derived from RuntimeError. In user defined base classes,
abstract methods should raise this exception when they require derived classes
to override the method. New in version 1.5.2. "

Of course if the above 2 assumptions are not true, I'm going to have to think
about it a bit more.

[1]http://docs.python.org/lib/module-exceptions.html
Comment 3 John Poelstra 2008-06-26 22:58:59 EDT
triaged
Comment 4 Miroslav Lichvar 2008-06-27 07:45:46 EDT
Ok, I've put the fix in upstream git. Will be in the next release.

Thanks.
Comment 5 Greg Swift 2008-06-27 11:30:21 EDT
awesome.  thanks.
Comment 6 Miroslav Lichvar 2008-07-30 09:29:59 EDT
Fixed in newt-0.52.10-1.fc10.
Comment 7 Fedora Update System 2008-07-30 09:42:36 EDT
newt-0.52.10-1.fc9 has been submitted as an update for Fedora 9
Comment 8 Fedora Update System 2008-09-10 03:05:41 EDT
newt-0.52.10-1.fc9 has been pushed to the Fedora 9 stable repository.  If problems still persist, please make note of it in this bug report.

Note You need to log in before you can comment on or make changes to this bug.