python c interface problems

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • saintlyav
    New Member
    • Mar 2007
    • 1

    #1

    python c interface problems

    I recently made a python module which calls functions from a c program. I used SWIG to generate the wrapper code from an interface file, and compiled the module into a dll which i can import in python and call functions from. While some of the functions are working fine, the others are giving serious errors like:

    Python 2.4.3 (#1, May 18 2006, 07:40:45)
    [GCC 3.3.3 (cygwin special)] on cygwin
    Type "help", "copyright" , "credits" or "license" for more information.
    >>> import agent
    >>> agent.dummy_foo ()
    agent::dummy_fo o called!!
    x val is: 25
    0
    >>> agent.get_agent _property(40,12 ,"agentclass ")
    you are in get_agent_prope rty:
    40 [main] python 5216 _cygtls::handle _exceptions: Error while dumping state
    (probably corrupted stack)
    Segmentation fault (core dumped)


    As shown above, i have no problem calling a dummy function, but when i call the other function, i get the "corrupted stack" and "segmentati on fault" errors. I am running these on Cygwin.

    Could anyone help me out with this?
  • bartonc
    Recognized Expert Expert
    • Sep 2006
    • 6478

    #2
    Originally posted by saintlyav
    I recently made a python module which calls functions from a c program. I used SWIG to generate the wrapper code from an interface file, and compiled the module into a dll which i can import in python and call functions from. While some of the functions are working fine, the others are giving serious errors like:

    Python 2.4.3 (#1, May 18 2006, 07:40:45)
    [GCC 3.3.3 (cygwin special)] on cygwin
    Type "help", "copyright" , "credits" or "license" for more information.
    >>> import agent
    >>> agent.dummy_foo ()
    agent::dummy_fo o called!!
    x val is: 25
    0
    >>> agent.get_agent _property(40,12 ,"agentclass ")
    you are in get_agent_prope rty:
    40 [main] python 5216 _cygtls::handle _exceptions: Error while dumping state
    (probably corrupted stack)
    Segmentation fault (core dumped)


    As shown above, i have no problem calling a dummy function, but when i call the other function, i get the "corrupted stack" and "segmentati on fault" errors. I am running these on Cygwin.

    Could anyone help me out with this?
    If you have done the string interface correctly, then the problem must be in the C part, because the string is the only thing that will allocate memory in the interface.

    Comment

    Working...