Need help with strange segfault

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mitko Haralanov

    Need help with strange segfault

    I am attempting to get a working wrapper around the TransactionSet
    class from the rpm module but I am getting unexplained segfaults
    in /usr/bin/python.

    The reason why I am working on a wrapper is that I want to have a
    single RPM abstraction module which is thread-safe and does not tie up
    the RPM database. So here is my wrapper class:

    class Transaction:
    def __init__ (self, db=None):
    self.ts = None
    self.ts_lock = Lock ()
    self.db = db
    self.func = None

    # This method will acquire the lock, record the TransactionSet
    # method being called by the caller and return the pointer to
    # the call_ts_func () function, which will do all the work.
    def __getattr__ (self, name):
    self.ts_lock.ac quire ()
    self.func = name
    return self.call_ts_fu nc

    # This method serves as a wrapper around the actual TransactionSet
    # method being called. It will open the database, call the
    # TransactionSet method, close the databse, and then release the
    # lock acquired in the __getattr__ () function.
    def call_ts_func (self, *args):
    if not self.ts:
    if self.db: rpm.addMacro ("_dbpath", self.db)
    self.ts = rpm.Transaction Set ()
    self.ts.openDB ()
    if self.db: rpm.delMacro ("_dbpath")

    func = self.ts.__getat tribute__ (self.func)
    rs = func (*args)

    self.func = None
    self.ts.clean ()
    self.ts.closeDB ()
    del self.ts
    self.ts = None
    self.ts_lock.re lease ()
    return rs

    I am getting what appears to be a correct value in rs but as soon as I
    try to access it from the caller function, Python segfaults.

    Any help would be appreciated?

    --
    Mitko Haralanov mitko@qlogic.co m
    Senior Software Engineer 650.934.8064
    System Interconnect Group http://www.qlogic.com

    =============== =============== ============
    Any programming language is at its best before it is implemented and
    used.
Working...