From owner-freebsd-python@freebsd.org  Mon Aug 24 21:11:37 2015
Return-Path: <owner-freebsd-python@freebsd.org>
Delivered-To: freebsd-python@mailman.ysv.freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by mailman.ysv.freebsd.org (Postfix) with ESMTP id 673B89C1B7F
 for <freebsd-python@mailman.ysv.freebsd.org>;
 Mon, 24 Aug 2015 21:11:37 +0000 (UTC)
 (envelope-from naylor.b.david@gmail.com)
Received: from mail-wi0-x236.google.com (mail-wi0-x236.google.com
 [IPv6:2a00:1450:400c:c05::236])
 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
 (Client CN "smtp.gmail.com",
 Issuer "Google Internet Authority G2" (verified OK))
 by mx1.freebsd.org (Postfix) with ESMTPS id 102EE1B10
 for <freebsd-python@freebsd.org>; Mon, 24 Aug 2015 21:11:37 +0000 (UTC)
 (envelope-from naylor.b.david@gmail.com)
Received: by widdq5 with SMTP id dq5so62017585wid.1
 for <freebsd-python@freebsd.org>; Mon, 24 Aug 2015 14:11:35 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
 h=sender:from:to:subject:date:message-id:organization:user-agent
 :mime-version:content-type;
 bh=hWcF59fYtE/u9miyTzkTgJ/l9wPZqpaHV+hUMr2CWOA=;
 b=kA0mhDH4rYDdgfNxYLkqi9zIK1ay/DshGTpUUanfaVnqeo99xBjqgoztcmB9ZLoGdT
 ZIaIRuahBh2WJ5sYRqfJG+/uGgbIlLIpZ4stxX9q8ePZYJZWRcYcKyFGe8pWXoGzAI91
 3bSu7g56lLZxYqPebOQAVs+Qm/brULx8Tzi6j3tJTX5FNe9pc/1dkVkaYfUWxbzHn3UT
 KITIve30vyiM1W6nfAmhFT/ogchivO+EGTxQC6Cye3FkXCGNwq4L4oBXsD8JxpKLjYGe
 /gJr83u/e6L9KsR5GoC6XYitktspQ0XVaMpEGPmeqaVaNGT3E5JoVpoh1TYS/AYrVQ8x
 KqjA==
X-Received: by 10.194.59.100 with SMTP id y4mr46023270wjq.151.1440450695623;
 Mon, 24 Aug 2015 14:11:35 -0700 (PDT)
Received: from dragon.local ([197.87.121.41])
 by smtp.googlemail.com with ESMTPSA id ll1sm17863715wic.14.2015.08.24.14.11.34
 for <freebsd-python@freebsd.org>
 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
 Mon, 24 Aug 2015 14:11:35 -0700 (PDT)
Sender: David Naylor <naylor.b.david@gmail.com>
From: David Naylor <dbn@freebsd.org>
To: freebsd-python@freebsd.org
Subject: ctypes not working (Fwd: [pypy-dev] 2.6.1 and freebsd-9)
Date: Mon, 24 Aug 2015 23:11:32 +0200
Message-ID: <1770820.q6b9lEKF14@dragon.local>
Organization: FreeBSD
User-Agent: KMail/4.14.3 (FreeBSD/10.2-RELEASE; KDE/4.14.3; amd64; ; )
MIME-Version: 1.0
Content-Type: multipart/signed; boundary="nextPart6993704.WiLQnoTmjT";
 micalg="pgp-sha512"; protocol="application/pgp-signature"
X-BeenThere: freebsd-python@freebsd.org
X-Mailman-Version: 2.1.20
Precedence: list
List-Id: FreeBSD-specific Python issues <freebsd-python.freebsd.org>
List-Unsubscribe: <https://lists.freebsd.org/mailman/options/freebsd-python>, 
 <mailto:freebsd-python-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-python/>
List-Post: <mailto:freebsd-python@freebsd.org>
List-Help: <mailto:freebsd-python-request@freebsd.org?subject=help>
List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/freebsd-python>,
 <mailto:freebsd-python-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Mon, 24 Aug 2015 21:11:37 -0000


--nextPart6993704.WiLQnoTmjT
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset="us-ascii"

Hi list,

Please see the correspondence below from the pypy team about some faili=
ng=20
tests.  Specifically, why is test.py producing None whereas test.c is=20=

producing the desired results? =20

Regards

=2D---------  Forwarded Message  ----------

Subject: Re: [pypy-dev] 2.6.1 and freebsd-9
Date: Monday, 24 August 2015, 23:07:20
From: David Naylor <naylor.b.david@gmail.com>
To: pypy-dev@python.org
CC: Matti Picus <matti.picus@gmail.com>

On Saturday, 22 August 2015 21:25:44 Matti Picus wrote:
> I would like to add the freebsd-9-x86-64 binary tgz to our released
> downloads. We still have a number of failing tests showing up on
> http://buildbot.pypy.org/summary?category=3Dfreebsd64
> among them many
> DLOpenError: "opening 'libm.so' with ctypes.CDLL() works, but not wit=
h
> c_dlopen()??"
> and the more worrying SIGSEGV in
> http://buildbot.pypy.org/summary/longrepr?testname=3Dunmodified&build=
er=3Dpypy-c
> -jit-freebsd-9-x86-64&build=3D655&mod=3Dlib-python.2.7.test.test_io
>=20
> Could someone proficient in freebsd suggest what is going on?

Hi Matti,

I am able to reproduce this on FreeBSD 10.2:
# cat > test.py << __EOF
from=20ctypes import *

libc =3D CDLL("libc.so.7")
dlopen =3D libc["dlopen"]

# see <dlfnc.h>: void    *dlopen(const char *, int);
dlopen.argtypes =3D [c_char_p, c_int]
dlopen.restype =3D c_void_p

print dlopen(c_char_p("libm.so"), c_int(0))
__EOF
# python test.py
None

However, contract this with the C equivalent:
# cat > test.c << __EOF
#include <dlfcn.h>
#include <stdio.h>

int main(int argc, char** argv)
{
    printf("%p\n", dlopen("libm.so", RTLD_LOCAL));
}
__EOF
# cc -o test test.c
# ./test
0x800620800

<snip/>

--nextPart6993704.WiLQnoTmjT
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: This is a digitally signed message part.
Content-Transfer-Encoding: 7Bit

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQJ8BAABCgBmBQJV24iEXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w
ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQ5NDhFQzUxMUEyN0YwMzAyRTc5OUI1M0FB
RDYzRkE4REQ2QjJEQTU1AAoJEK1j+o3WstpVLr0P/0Cx2uR+p04Y+51JbTGZXeNr
LSj23qbP10FIHUc1oGJh5f8MUJBVl7zH+fA9hjek4ZTg8aNx8h02f43E4z7oEO+T
MLuqgqpLufOk2e9D8gXw7g8hJGDY2OlTDAJ8gnhqWj4gLc2dpLZAAyXz6LJVa61m
5uBFyQ5SqC3IPyYzpPDzn2ZOLbXoLQWe4msE9O5TJMXgVtylRNEvs4p/oVGOOw8u
QGHUFcemi2BKfoNAyEQ0AZOobtSyINnSpYwd2wqkY448WzDClwOF8Oi6Ts7ybppY
eLPRywqM7DKgqW8TyQBE/n+LxIDZKOsHucxxoV+8oRJlPUmQl0AqcfYtp/kJUtVE
sz2RubtKMrNEqfm30uX0KLPpQtZDItaSltnXvWMpB4qEcrpEUGw9B8ez5+LkWgNl
wXtrehISqH4PyZqbLG1LISgD3Drv/8OaBfbeLqH5UI3cxO0oWYtvlA0HeHShTD/D
ZTr44qF9mnN+qoFzq7LYJGLAyLlk1EsXh8EUL9zzVs6xHPEmHoTt9WUvIxQrTIsl
9mPhzuIMBpyRXDpKOk5ldH0Ma6X7HFYlnE/iasYR1chx8OW6bKUPATx50+7DR5oa
xs56D83DUgSgW7/jp/ap+VzXFGTPcHRwG7lCj0YBUe8yYLTJdY9i4lvJOgHTwITa
S1ZK13jIVoYHDHaa7SUt
=0Atp
-----END PGP SIGNATURE-----

--nextPart6993704.WiLQnoTmjT--