On Apr 21, 2008, at 11:47 AM, Johannes Wienke wrote:
Hi,Am 04/21/2008 07:00 PM schrieb Robert Bradshaw:When you write cdef char* s = x where x is a Python object, it sets s to a pointer of the data of s. This is why you don't have to worry about allocating/deallocating s. However, if you try to use s after x has gone out of scope/has been garbage collected, s may contain garbage. Perhaps this is what'shappening here, and if that's the case you need to allocate s manuallyand strcpy the contents of the string over.I've also though of this, but that doesn't help, either. While tryingaround a bit I've observed that I don't get a segfault if only C code is used inside the function. Any Python code, even if not dealing with the variables, results in a segfault. For example this means a segfault, too:cdef public void plug_observ_data(plugDefinition *p, const_char_ptr i):print "test" Whereascdef public void plug_observ_data(plugDefinition *p, const_char_ptr i):puts("test") works without a problem.
Is the callback being used in an asynchronous way? If so, you may have to acquire the GIL (Search for GIL and pyrex/cython/python for a basic background on what the GIL is).
PGP.sig
Description: This is a digitally signed message part
_______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
