473,408 Members | 2,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

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.acquire ()
self.func = name
return self.call_ts_func

# 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.TransactionSet ()
self.ts.openDB ()
if self.db: rpm.delMacro ("_dbpath")

func = self.ts.__getattribute__ (self.func)
rs = func (*args)

self.func = None
self.ts.clean ()
self.ts.closeDB ()
del self.ts
self.ts = None
self.ts_lock.release ()
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 mi***@qlogic.com
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.
Sep 5 '07 #1
0 884

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Robert Frunzke | last post by:
Hello, I'm developing a php extension as a communication layer for a proprietary database. Now, when I run two different versions of this extension on the same webserver (Apache 3, PHP 4.3.3,...
7
by: devesh.agrawal | last post by:
Hi , this program does a segfault in g++3.2 onwards , works with g++2.95 , Any ideas are welcome , basically there is this instruction when compiled with -S option , call *%eax , where the one...
4
by: Ovid | last post by:
Hi all, I'm having a problem trying to create a 2D array whose dimensions are determined at runtime. Below my signoff is a minimal test case that hopefully demonstrates what I'm trying to do. ...
6
by: Code Raptor | last post by:
Folks, I am hitting a segfault while free()ing allocated memory - to make it short, I have a linked list, which I try to free node-by-node. While free()ing the 28th node (of total 40), I hit a...
9
by: Eric Lilja | last post by:
Hello, I have two code snippets I want you to look at. My program compiles without warnings (warning level set to max, gcc 3.4.3) with either snippet but the latter one causes a segfault at...
30
by: James Daughtry | last post by:
char array; scanf("%19s", &array); I know this is wrong because it's a type mismatch, where scanf expects a pointer to char and gets a pointer to an array of 20 char. I know that question 6.12...
4
by: FBM | last post by:
Hi, I am working on a program that simulates one of the elements of ATM. The simulation stores events which occurs every some milliseconds for a certain amount of time. Every time that an event...
14
by: ptq2238 | last post by:
Hi, I'm getting confused with arrays and hope someone can shed light on my code. I wrote this to try and learn about files and arrays as I thought if I could grab each element and place them into...
1
by: Miles Lubin | last post by:
I am using PyArg_ParseTuple to parse the arguments (ignoring the keyword arguments) to my initproc for a type I define. It seems that something goes wrong inside PyArg_ParseTuple when it gets the...
160
by: DiAvOl | last post by:
Hello everyone, Please take a look at the following code: #include <stdio.h> typedef struct person { char name; int age; } Person;
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.