Python bindings on Windows crash
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)
-
-
reporter Those certainly won’t work on Linux or OSX….
uintptr_t ?
https://stackoverflow.com/questions/1845482/what-is-uintptr-t-data-type
or is there something specifically compatible with ctypes?
-
“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.
-
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.
-
Can you use size_t? it is unsigned and the size 32bit on x86 vs 64bit on x64
-
reporter - attached window-pointer-size
updated patch, uses size_t
-
reporter The packaged ode just became available on conda-forge
more info on https://github.com/conda-forge/libode-feedstock
-
Merged into trunk with revision 2203
-
- changed status to resolved
-
Also, the patch has been merged into “0.16.x” branch with revision 2205
-
- removed version
Removing version: 0.16 (automated comment)
- Log in to comment
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