473,387 Members | 1,423 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,387 software developers and data experts.

PyGILState_Release produces a seg fault

Hello and happy new year folks,

I am experiencing a seg fault while using the python interface to
the VTK library (debian oldstable, python 2.3). The VTK library is
wrapped by a custom mechanism to provide a python API. In particular
they implemented a way so that a python function can be called in
response to an event(*). Basically all the code is doing is:

{
PyGILState_STATE state = PyGILState_Ensure();
// construct arglist from C++ args:
...
// call python function:
result = PyEval_CallObject(this->obj, arglist);

PyGILState_Release(state); // crash happens here
}

However the event being triggered from the C++ layer is done from
multiple threads. After reading :

http://docs.python.org/api/threads.html

I tought that the VTK-python layer was simply missing a call to :
PyEval_InitThreads() just before Py_InitModule(), but now my python
shell appears as hung ! The only solution I found is that if I comment
out the function calls PyGILState_Ensure/PyGILState_Release then
everything goes smoothly.

Am I reading the docs backward ? I do need to keep the call to
PyGILState_Ensure/PyGILState_Release, right ?

I am also copying the log from valgrind (VTK lib untouched, no call
to PyEval_InitThreads), UpdateProgress being the function called from
multiple threads:

==20066== Thread 2:
==20066== Invalid read of size 4
==20066== at 0x403232A: sem_post@@GLIBC_2.1 (in /usr/lib/debug/
libpthread-2.5.so)
==20066== by 0x80B0D53: PyEval_ReleaseLock (in /usr/bin/python2.4)
==20066== by 0x80DDB20: PyGILState_Release (in /usr/bin/python2.4)
==20066== by 0x45C7AB4: vtkPythonCommand::Execute(vtkObject*,
unsigned long, void*) (vtkPythonUtil.cxx:2016)
==20066== by 0x483C0DF: vtkSubjectHelper::InvokeEvent(unsigned
long, void*, vtkObject*) (vtkObject.cxx:547)
==20066== by 0x483C18E: vtkObject::InvokeEvent(unsigned long,
void*) (vtkObject.cxx:713)
==20066== by 0x4E67E6A: vtkAlgorithm::UpdateProgress(double)
(vtkAlgorithm.cxx:115)

Thanks,
-Mathieu

Original post:
http://public.kitware.com/pipermail/...ry/004890.html

(*) See line 1906->2019 at:
http://public.kitware.com/cgi-bin/vi...?annotate=1.80
Jan 10 '08 #1
0 1156

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

Similar topics

1
by: Phil Powell | last post by:
Consider these two classes. Class Accepter in placement_classes.inc.php works as a form validation object, and it works like a charm: PHP: // placement_classes.inc.php - THIS ONE WORKS! ...
2
by: Mathias Mamsch | last post by:
Hi all, i am writing a python extension in c++. In the extension a c++ thread calls back into python. I did it like this: ---- c++ code ---- PyGILState_STATE gstate; gstate =...
4
by: Randall Hopper | last post by:
What is the correct way to propagate exceptions from Python callbacks? When I do this: Python -> C++ -> Python Callback (example attached) an exception raised in the callback doesn't make it...
1
by: Jean-David Beyer | last post by:
I am presently running DB2 V8.1.6 on Red Hat Enterprise Linux 3 ES. Every second, the following messages appear in my /var/log/messages file: Jul 10 09:04:45 kernel: application bug:...
0
by: Matt S | last post by:
Hello, I'm trying to build a C# client to consume an AXIS Web Service (running SOAP over HTTP). The Web Service encodes full server-side exception traces in the Soap Fault > Detail element...
1
by: Kirill Simonov | last post by:
Hi, Could someone tell me why my extension module works under Python 2.4, but fails with Segmentation Fault under Python 2.3? Here is the stripped version: ...
1
by: geoffschmidt | last post by:
I'm trying to write an extension in C that delivers callbacks to Python. The C code starts several threads, and I'd like one of the new threads that is started to be able to deliver callbacks to...
2
by: Rolf Magnus | last post by:
Ioannis Vranos wrote: I think you did. Here, the object changes the value used for operator< when copied, which is likely to lead to problems with sorting your container of SomeClass...
3
by: jr.freester | last post by:
I have created to classes Matrix and System. System is made up of type matrix. ---------------------------------------------------------------------------------- class Matrix { private: int...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.