[Pyrex] strange pointer behaviour in python shared library

Lenard Lindstrom len-l at telus.net
Wed Nov 2 20:45:03 CET 2005


It doesn't look like a stack overflow or memory leak. But more 
information is needed to narrow down the problem. From your 
explanation it was not clear that you checked if the right value was 
passed to xltEncPcdata at the point it was called. Are you sure that 
on the 27th call it was not passed 0x19 for pContent?

Lenard Lindstrom
<len-l at telus.net>


On 2 Nov 2005 at 16:36, Anthony Percy wrote:

> 
> Hi Pyrex list!
> I wounder if I could ask your collective advice?
> I have used Pyrex (fantastic tool!) to provide an interface to the 
> shared library in python and it works fine when I call a single high 
> level function that calls sub functions that call shared library 
> function etc.
> Now I have altered the Pyrex interface to call the sub functions 
> directly and I get segmentation errors!
> I believe this is not related to Pyrex but I am baffled as to what is 
> going on .....
> I have traced the fault using ddd and I can't quite believe what I am 
> seeing...
> 
> The problem is in a const void pointer that is passed in a function 
> call to a number of functions as a pointer to a structure member.
> e.g "const void pContent" that is used as "pContent->fred" . (I 
> should mention pContent is cast to the structure type)
> It works fine for 26 calls to the function e.g xltEncPcdata ( 
> ....... const void pContent, ......) in that the pContent value is 
> say 0x801934.
> Then on the 27th call to the same function it has the value say 
> 0x801934 but as soon as the first "{" is passed , e.g as it enteres 
> the function body without executing any line, pContent changes to say 
> 0x19 !!!!
> Of course when say pContent->fred is accessed, up pops the 
> segmentation error.
> I have chnged to a newer version of gcc but I get the same results.
> Also sometimes, it will just error without the seg error. e.g return 
> codes indicate an error.
> 
> Could anyone offer any advice as to what is going on?
> Is this the python stack runnning out of space? or a memory leak?
> I have coded C etc in the past but the python bits are new to me... 
> Any advice would be greatly appreciated...
> 
> Regards
> 
> Anthony Percy





More information about the Pyrex mailing list