[ python-Bugs-1470353 ] test_ctypes fails on FreeBSD 4.x

SourceForge.net noreply at sourceforge.net
Sun Apr 16 05:03:22 CEST 2006


Bugs item #1470353, was opened at 2006-04-14 23:11
Message generated for change (Comment added) made by aimacintyre
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1470353&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Closed
Resolution: Fixed
Priority: 5
Submitted By: Andrew I MacIntyre (aimacintyre)
Assigned to: Thomas Heller (theller)
Summary: test_ctypes fails on FreeBSD 4.x

Initial Comment:
$ ./python Lib/test/regrtest.py test_ctypes
test_ctypes
test test_ctypes failed -- Traceback (most recent call
last):
  File
"/home/andymac/dev/python-svn-head/Lib/ctypes/test/test_functions.py",
line 333, in test_struct_return_2H
    self.failUnlessEqual((s2h.x, s2h.y), (99*2, 88*3))
AssertionError: (-1004, 2123) != (198, 264)

1 test failed:
    test_ctypes
[41158 refs]

This is with a subversion checkout updated to 5am AEST
(Aust) 14Apr06, debug build.

The returned tuple values (s2h.x, s2h.y) appear to vary
from run to run, so it looks like something isn't where
its expected.

This is with a FreeBSD 4.8 i386 system (not
particularly recent), using gcc 2.95.4.  A quick and
dirty test (in C) suggests that its not an alignment
issue for the 2 shorts in the S2H struct.

Ideas for trying to debug this further?

----------------------------------------------------------------------

>Comment By: Andrew I MacIntyre (aimacintyre)
Date: 2006-04-16 13:03

Message:
Logged In: YES 
user_id=250749

In that case, it would be worth confirming whether later
versions of FreeBSD (at least 5.4, better 6.0) are also
affected.  I don't know whether there's anyone from
DragonflyBSD active - its a FreeBSD 4.x offshoot.

----------------------------------------------------------------------

Comment By: Thomas Heller (theller)
Date: 2006-04-16 06:26

Message:
Logged In: YES 
user_id=11105

Committed as 45440.

For NetBSD, this change seems not to be required - ctypes
works fine as it is (I'm testing this on the SF compilefarm
host, which has NetBSD 2.0.2).

----------------------------------------------------------------------

Comment By: Andrew I MacIntyre (aimacintyre)
Date: 2006-04-15 21:18

Message:
Logged In: YES 
user_id=250749

Your suggested change does indeed get the test to pass on
this system.  Given the history and relationship of
[Free/Net/Open]BSD, I would suggest that for x86 it is very
likely that you will need to add defined(__NetBSD__) clauses
as well.

>From my POV this bug can now be closed.

Thanks, Thomas.

BTW, the actual patch applied was:
--- ffi.c.orig  Tue Apr  4 05:26:32 2006
+++ ffi.c       Sat Apr 15 21:02:16 2006
@@ -121,7 +121,7 @@
   switch (cif->rtype->type)
     {
     case FFI_TYPE_VOID:
-#if !defined(X86_WIN32) && !defined(__OpenBSD__)
+#if !defined(X86_WIN32) && !defined(__OpenBSD__) &&
!defined(__FreeBSD__)
     case FFI_TYPE_STRUCT:
 #endif
     case FFI_TYPE_SINT64:
@@ -135,7 +135,7 @@
       cif->flags = FFI_TYPE_SINT64;
       break;

-#if defined(X86_WIN32) || defined(__OpenBSD__)
+#if defined(X86_WIN32) || defined(__OpenBSD__) ||
defined(__FreeBSD__)
     case FFI_TYPE_STRUCT:
       if (cif->rtype->size == 1)
         {


----------------------------------------------------------------------

Comment By: Thomas Heller (theller)
Date: 2006-04-15 05:09

Message:
Logged In: YES 
user_id=11105

Of course I meant FreeBSD instead of NetBSD, sorry.

----------------------------------------------------------------------

Comment By: Thomas Heller (theller)
Date: 2006-04-15 05:08

Message:
Logged In: YES 
user_id=11105

This looks very similar to a problem I recently 'fixed' on
OpenBSD - maybe it is even a bug in libffi.  On OpenBSD x86
the problem seemed to be that small structures are passed
like  short or int.  You could try to fix it by adding the
appropriate definition in
Modules/_ctypes/libffi/src/x86/ffi.c, at lines 124 and lines
138.  Maybe changing them to

#if !defined(X86_WIN32) && !defined(__OpenBSD__) &&
!defined(__NetBSD__)

or whatever the magic symbol for Netbsd is.

Unfortunately I do not have access to a netbsd machine myself.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1470353&group_id=5470


More information about the Python-bugs-list mailing list