Issue 1470353: test_ctypes fails on FreeBSD 4.x (original) (raw)

Created on 2006-04-14 13:11 by aimacintyre, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (7)
msg28228 - (view) Author: Andrew I MacIntyre (aimacintyre) * (Python triager) Date: 2006-04-14 13:11
$ ./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?
msg28229 - (view) Author: Thomas Heller (theller) * (Python committer) Date: 2006-04-14 19:08
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.
msg28230 - (view) Author: Thomas Heller (theller) * (Python committer) Date: 2006-04-14 19:09
Logged In: YES user_id=11105 Of course I meant FreeBSD instead of NetBSD, sorry.
msg28231 - (view) Author: Andrew I MacIntyre (aimacintyre) * (Python triager) Date: 2006-04-15 11:18
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)
msg28232 - (view) Author: Thomas Heller (theller) * (Python committer) Date: 2006-04-15 20:26
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).
msg28233 - (view) Author: Andrew I MacIntyre (aimacintyre) * (Python triager) Date: 2006-04-16 03:03
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.
msg28234 - (view) Author: Thomas Heller (theller) * (Python committer) Date: 2006-04-16 20:19
Logged In: YES user_id=11105 I can confirm that both current Python SVN as well as ctypes CVS pass the testsuite under FreeBSD 6.0.
History
Date User Action Args
2022-04-11 14:56:16 admin set github: 43202
2006-04-14 13:11:34 aimacintyre create