472,357 Members | 1,937 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Segmentation Fault on CDLL reloading

Hi,

I use the following ctype to load a .so library in Linux.

vr = ctypes.CDLL(sstr)

And the following to release it so that i can reload the library without
quiting the python script.

_ctypes.dlclose(vr._handle)

These calls are guarded by a writer lock and access to it guarded by a
reader lock which i got from recipe :
http://code.activestate.com/recipes/413393/

The problem is during the re-loading of the library occasionally the
python script will abort with "Segmentation Fault". This is like 1 out
of 10 times it can happen and that
is good enough to kill the application.

Is there any reason to this or how to do i prevent it?
Marcus .CM


Aug 30 '08 #1
1 2522
Marcus.CM schrieb:
Hi,

I use the following ctype to load a .so library in Linux.

vr = ctypes.CDLL(sstr)
And the following to release it so that i can reload the library without
quiting the python script.

_ctypes.dlclose(vr._handle)

These calls are guarded by a writer lock and access to it guarded by a
reader lock which i got from recipe :

The problem is during the re-loading of the library
occasionally the python script will abort with "Segmentation Fault".
This is like 1 out of 10 times it can happen and that
is good enough to kill the application.

Is there any reason to this or how to do i prevent it?
Short answer: yes, there is a reason, no, you can't prevent it.

Of course there is a reason for this. Segfaults don't happen by
chance... And one can't prevent segfaults from killing the interpreter,
because the OS is responsible for that.

Now what would I do?

- don't care. Or does the DLL frequently change when the program is
deployed? Or to ask different: why do you need unloading/reloading at all?

- debug it. Write a script that exposes the behavior. The fire up GDB
with python, do "set args <myscript>" and run. When the segfault occurs,
look into the traceback with "bt". If the problem is in the DLL-code,
see what's causing it. If it's in ctypes (or the python-interpreter) -
well, there is a ctypes mailing lisk to ask for help.

Diez
Aug 30 '08 #2

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

Similar topics

2
by: sivignon | last post by:
Hi, I'm writing a php script which deals with 3 ORACLE databases. This script is launch by a script shell on an linux machine like this : /../php/bin/php ./MySript.php (PHP 4.3.3) My script...
3
by: Zheng Da | last post by:
Program received signal SIGSEGV, Segmentation fault. 0x40093343 in _int_malloc () from /lib/tls/libc.so.6 (gdb) bt #0 0x40093343 in _int_malloc () from /lib/tls/libc.so.6 #1 0x40094c54 in malloc...
5
by: Fra-it | last post by:
Hi everybody, I'm trying to make the following code running properly, but I can't get rid of the "SEGMENTATION FAULT" error message when executing. Reading some messages posted earlier, I...
18
by: Digital Puer | last post by:
Hi, I'm coming over from Java to C++, so please bear with me. In C++, is there a way for me to use exceptions to catch segmentation faults (e.g. when I access a location off the end of an array)?...
27
by: Paminu | last post by:
I have a wierd problem. In my main function I print "test" as the first thing. But if I run the call to node_alloc AFTER the printf call I get a segmentation fault and test is not printed! ...
7
by: pycraze | last post by:
I would like to ask a question. How do one handle the exception due to Segmentation fault due to Python ? Our bit operations and arithmetic manipulations are written in C and to some of our...
3
by: madunix | last post by:
My Server is suffering bad lag (High Utlization) I am running on that server Oracle10g with apache_1.3.35/ php-4.4.2 Web visitors retrieve data from the web by php calls through oci cobnnection...
6
by: DanielJohnson | last post by:
int main() { printf("\n Hello World"); main; return 0; } This program terminate just after one loop while the second program goes on infinitely untill segmentation fault (core dumped) on...
3
by: patelss23 | last post by:
Hello All, I am dealing with this weird bug. I have a function in C and I have written python bindings for it using ctypes. I can call this function for couple of times and then suddenly it...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
0
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...

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.