SWIG - python.exe crash

Discussion in 'Python' started by Java and Swing, Oct 4, 2005.

  1. When I try to print an object in Python, python.exe crashes. Below
    are my files.

    defs.h
    ------------------------------------------------------------------------------------------------------
    typedef unsigned long MY_DIGIT;


    myapp.c
    ------------------------------------------------------------------------------------------------------
    void MakeDigits(MY_DIGIT digits[]) {
    ....
    }

    char* GetString(char *inMessage, MY_DIGIT *digit) {
    char *results;
    ...
    ...
    return results;
    }


    MyApp.i
    ------------------------------------------------------------------------------------------------------
    %module MyApp
    %{
    #include "math.h"
    %}

    extern void MakeDigits(MY_DIGIT digits[]);
    extern char* GetString(char *inMessage, MY_DIGIT *digit);

    /* allows for the creation of a MY_DIGIT array */
    %inline %{
    MY_DIGIT *my_digit_array(int size) {
    return (MY_DIGIT *) malloc(size * sizeof(int));
    }
    %}


    ....I have two questions.

    1) One, I call MakeDigits which should populate the "digits" array with
    some values. It seems the first time I try it the digits array is
    populated. Then if I try to re-use the digits array i get some garbage
    output. But if I recall MakeDigits...I can then re-use the digits
    array over and over without anymore problems? Any idea?
    here is how I was trying it...
    digits = my_digit_array(10)
    MakeDigits(digits)

    2) When I try to print the "my_digit_array" object, python.exe
    crashes...below is the code I use to cause this problem: (within
    python)
    digits = my_digit_array(10)
    print digits

    I am using Python 2.4.1, Swig 1.3.25 on Win XP Pro.

    I tried sending a message on the SWIG mailing list...but so far it
    hasn't shown up on the list...I've sent it three times now. I'll keep
    trying.
    Java and Swing, Oct 4, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Q2hyaXM=?=

    w3wp.exe Crash, Session Unload, Event ID 1000

    =?Utf-8?B?Q2hyaXM=?=, Dec 21, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    9,339
    =?Utf-8?B?c3RpbmU=?=
    Mar 5, 2006
  2. Jon Moldover
    Replies:
    0
    Views:
    297
    Jon Moldover
    Oct 28, 2003
  3. Chaos
    Replies:
    1
    Views:
    406
  4. waldek

    python.exe crash and ctypes use

    waldek, Jul 23, 2008, in forum: Python
    Replies:
    3
    Views:
    296
    waldek
    Jul 24, 2008
  5. Replies:
    1
    Views:
    73
    Tim Golden
    Jul 3, 2013
Loading...

Share This Page