From owner-freebsd-python@FreeBSD.ORG  Fri Jun  7 19:14:23 2013
Return-Path: <owner-freebsd-python@FreeBSD.ORG>
Delivered-To: python@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by hub.freebsd.org (Postfix) with ESMTP id 6BC80974
 for <python@freebsd.org>; Fri,  7 Jun 2013 19:14:23 +0000 (UTC)
 (envelope-from utisoft@gmail.com)
Received: from mail-ie0-x235.google.com (unknown
 [IPv6:2607:f8b0:4001:c03::235])
 by mx1.freebsd.org (Postfix) with ESMTP id 407AC1FB8
 for <python@freebsd.org>; Fri,  7 Jun 2013 19:14:23 +0000 (UTC)
Received: by mail-ie0-f181.google.com with SMTP id x14so11097456ief.26
 for <python@freebsd.org>; Fri, 07 Jun 2013 12:13:59 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
 h=mime-version:sender:in-reply-to:references:from:date
 :x-google-sender-auth:message-id:subject:to:content-type;
 bh=VxPNVO9dg6e4ZixQohxySLPnUproJFgLL2deZa7QxN0=;
 b=jQ7ftOZ4w31A9iUysl3qL2T2Nvfp8qknc26vB33XofeEgFvFSN+U/KOak+M6doRXhi
 3YfDmdkmCp1ocSoWc001zAVsxBwePkTUUZBoge1/xxoYQyd0Sr4u9WAq2PpBrBU1QZaM
 yQwda8n9E8oA/3PM6L6LPBQa949BLmK+HIe9uee4kFQ/YeJO7YwtYc4gCYagH+PPhCyJ
 o5MqF5bsuKNtTAgKjHwxNiDjwYoYESKSgChh2+6u59IEMsQl3RihmK2i7AO+uLxhLwnw
 bzhcZ//8JftUFn5HfLy7aYAnPsPdy40f+aJ0TbXR7ZGbEN8zF17VitNeQFV5e56BeVZ6
 DGdg==
X-Received: by 10.50.72.49 with SMTP id a17mr1839276igv.36.1370632439287; Fri,
 07 Jun 2013 12:13:59 -0700 (PDT)
MIME-Version: 1.0
Sender: utisoft@gmail.com
Received: by 10.64.71.101 with HTTP; Fri, 7 Jun 2013 12:13:29 -0700 (PDT)
In-Reply-To: <DC0C5FC7-C9A2-4158-9560-501B96B0E5C2@xcllnt.net>
References: <201305251859.r4PIxChc053341@svn.freebsd.org>
 <51AC9933.7050201@FreeBSD.org>
 <DC0C5FC7-C9A2-4158-9560-501B96B0E5C2@xcllnt.net>
From: Chris Rees <crees@FreeBSD.org>
Date: Fri, 7 Jun 2013 20:13:29 +0100
X-Google-Sender-Auth: HB2-LuCmYCfN2ee05teKye2GzXQ
Message-ID: <CADLo839GDyM9HV=cnuwCjdiBH4tELR9qqV1ZC_x=GfsbzeLb7Q@mail.gmail.com>
Subject: Fwd: svn commit: r250991 - in head: contrib/jemalloc/include/jemalloc
 include lib/libc/stdlib/jemalloc
To: python <python@freebsd.org>, Marcel Moolenaar <marcel@xcllnt.net>, 
 Tijl Coosemans <tijl@coosemans.org>, Florian Smeets <flo@smeets.im>
Content-Type: text/plain; charset=ISO-8859-1
X-BeenThere: freebsd-python@freebsd.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: FreeBSD-specific Python issues <freebsd-python.freebsd.org>
List-Unsubscribe: <http://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: <http://lists.freebsd.org/mailman/listinfo/freebsd-python>,
 <mailto:freebsd-python-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Fri, 07 Jun 2013 19:14:23 -0000

Hi all,

I don't know how many of you were following this, but it looks fine to
me... any of you mind if I commit it?

Chris


---------- Forwarded message ----------
From: Marcel Moolenaar <marcel@xcllnt.net>
Date: 3 June 2013 15:50
Subject: Re: svn commit: r250991 - in head:
contrib/jemalloc/include/jemalloc include lib/libc/stdlib/jemalloc
To: Dimitry Andric <dim@freebsd.org>
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, Marcel
Moolenaar <marcel@freebsd.org>, src-committers@freebsd.org



On Jun 3, 2013, at 6:25 AM, Dimitry Andric <dim@FreeBSD.org> wrote:

> On 2013-05-25 20:59, Marcel Moolenaar wrote:
>> Author: marcel
>> Date: Sat May 25 18:59:11 2013
>> New Revision: 250991
>> URL: http://svnweb.freebsd.org/changeset/base/250991
>>
>> Log:
>>   Make the malloc(3) family of functions weak and make their non-weak
>>   implementations visible for use by applications. The functions $F that
>>   are now weak symbols are:
>>      allocm, calloc, dallocm, free, malloc, malloc_usable_size,
>>      nallocm, posix_memalign, rallocm, realloc, sallocm
>>
>>   The non-weak implementations of $F are exported as __$F.
>
> Hi Marcel,
>
> This commit seems to lead to various problems in ports, and possibly
> other software.  For example, with Firefox I now always get a few
> messages like:
>
>  firefox in free(): warning: malloc() has never been called
>
> Another example is the devel/talloc port, which now dies with:

It looks like the python build is broken. The net effect is that _ctypes.so
has a strong definition of malloc, free, et al. This is not intentional,
but a side-effect of the what seems to be a bug in fficonfig.py.in (see
patch below). To elaborate:

_ctypes.so incorporates the libffi functionality for what I presume is
the basis for Python bindings. libffi includes dlmalloc.c, an open source
allocator. dlmalloc.c is incuded by closures.c and closures.c defines
USE_DL_PREFIX. On top of that closures.c makes all allocator functions
static. This, by design there's no problem. In short: dlmalloc.c never
gets compiler separately/independently.

The python build however compiles dlmalloc.c separately/independently.
As such, dlmalloc.c now defines and exports malloc et al and it also
get linked into _ctypes.so.

Once _ctypes.so gets dynamically loaded, things start to break.

Unfortunately, this means python needs to be recompiled from ports with
the following fix:

Index: files/patch-Modules-_ctypes-libffi-fficonfig.py.in
===================================================================
--- files/patch-Modules-_ctypes-libffi-fficonfig.py.in  (revision 0)
+++ files/patch-Modules-_ctypes-libffi-fficonfig.py.in  (working copy)
@@ -0,0 +1,10 @@
+--- Modules/_ctypes/libffi/fficonfig.py.in.orig        2013-06-03
07:16:44.000000000 -0700
++++ Modules/_ctypes/libffi/fficonfig.py.in     2013-06-03
07:17:03.000000000 -0700
+@@ -1,7 +1,6 @@
+ ffi_sources = """
+ src/prep_cif.c
+ src/closures.c
+-src/dlmalloc.c
+ """.split()
+
+ ffi_platforms = {

This has been tested with python-2.7.5. I can't say anything about
other versions.

Do people concur that this is the right fix?

--
Marcel Moolenaar
marcel@xcllnt.net


_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"