[Python-Dev] mingw32 and gc-header weirdness

Roumen Petrov bugtrack at roumenpetrov.info
Thu Jul 23 01:45:51 CEST 2009


Christian Tismer wrote:
> Hi all,
> 
> I was hacking to get mingw32 builds of psyco to work
> and found a pretty weird thing:
> 
> I used mingw32 (stable distro) to build the psyco extension
> on top of standard python2.6, built with Visual Studio,
> and got weird crashes.
> 
> The reason is in objimpl.h:
> 
> typedef union _gc_head {
>     struct {
>         union _gc_head *gc_next;
>         union _gc_head *gc_prev;
>         Py_ssize_t gc_refs;
>     } gc;
>     long double dummy;  /* force worst-case alignment */
> } PyGC_Head;
> 
> Mingw32 behaves funny here. The size of long double is 12 ! 8-)

No it is correct. GNU C compiler for windows support 80-bit extended 
precision.


> I happened to use the _PyObject_GC_UNTRACK macro in psyco, instead
> of the function, and that caused the errors, because psython
> and the extension disagreed on the location of the gc pointers...
> Using PyObject_GC_Untrack instead fixed the problem,
> but there is a bad feeling left.
> 
> Question:
> Is that considered a mingw bug?

No as sizeof(long double) = sizeof(double) is MSVC limitation.


> Should we change the above union to a safer construct?
> 
> Or maybe I just missed something obvious and made a fool out of me?
> 
> cheers - chris
> 

Regards,
Roumen


More information about the Python-Dev mailing list