[Pyrex] strange pointer behaviour in python shared library

Anthony Percy anthcp at gmail.com
Wed Nov 2 06:36:38 CET 2005


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.copyleft.no/pipermail/pyrex/attachments/20051102/c8f678db/attachment.html


More information about the Pyrex mailing list