Python bindings on Windows crash

Issue #64 resolved
Rene van Paassen created an issue

I am preparing windows/linux/osx packages of PyODE 0.16 for my students (and others) to use, they are currently a pull request in the staged-recipes for conda-forge here

In doing this, I found that the Windows version of an ode-using program would fail without warning, causing an immediate exit of the program.

From the compiler warnings on the Python binding, I found that the problem was that the Windows “long” int, (32 bit), cannot hold a pointer on Win64; this is used in ode.pxd and ode.pyd files. I replaced the appropriate longs by “long long”.

I created attached patch, currently in use for my conda recipe, which fixes the problem. I currently only apply the patch to the Windows build, but expect that it will seamlessly work on Linux and OSX as well.

Comments (11)

  1. Edgar 't Hart

    Normally you would use a DWORD* or a DWORD_PTR, this way the size is 64bit wide in a x64 process and 32bit wide in a x86 process

  2. Edgar 't Hart

    “long*” would also work. Or even a void*, I don’t know how the variable is used. Since it is used for containing a pointer, and it was a “long”, I guess there will be reinterpret_cast<..>'s.

    So void*, or long* will both probably work.

  3. Rene van Paassen reporter

    I just tried, it didn’t work.

    The pointer value is the key for keeping and finding references to the associated objects that are kept in a weakref dict. Cython complains that it cannot convert the pointers to python objects.

    The pointer value also seems to be used to call back through the C interface.

    And yes, there is some casting there.

    The people behind Linux and OSX had the foresight to make “long” equal to the pointer size; that is why it simply worked there.

  4. Log in to comment