From owner-freebsd-performance@FreeBSD.ORG Fri Jun 27 23:11:02 2003 Return-Path: Delivered-To: freebsd-performance@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E164D37B401 for ; Fri, 27 Jun 2003 23:11:02 -0700 (PDT) Received: from stoneport.math.uic.edu (stoneport.math.uic.edu [131.193.178.160]) by mx1.FreeBSD.org (Postfix) with SMTP id EBEA343FE3 for ; Fri, 27 Jun 2003 23:11:01 -0700 (PDT) (envelope-from djb-dsn-1056780693.64427@cr.yp.to) Received: (qmail 64428 invoked by uid 1017); 28 Jun 2003 06:11:33 -0000 Date: 28 Jun 2003 06:11:33 -0000 Message-ID: <20030628061133.64427.qmail@cr.yp.to> Automatic-Legal-Notices: See http://cr.yp.to/mailcopyright.html. From: "D. J. Bernstein" To: freebsd-performance@freebsd.org References: <20030626034138.88365.qmail@cr.yp.to> <3EFA9CA3.E616B54C@mindspring.com> <20030626210507.36261.qmail@cr.yp.to> <3EFC1B2A.344674DD@mindspring.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: Re: The dangers of replacing malloc() X-BeenThere: freebsd-performance@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Performance/tuning List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Jun 2003 06:11:03 -0000 Terry Lambert writes: > My argument in this case is that the valloc() interface is not > portable, and you should not use it. kqueue isn't portable, so you're saying nobody should use that, right? Or do you admit that it's actually a good idea for people to use kqueue, with a compile-time fallback to poll or select? Great. Now, what happens when some other system decides to emulate kqueue (not a huge surprise), using valloc (or some future xyzalloc), which in turn uses sbrk directly (as valloc already does on a huge number of systems, and as xyzalloc will probably do), rather than calling malloc? That's right: it obliterates the data that I obtained from sbrk in my malloc replacement. Kaboom. This is exactly the failure mode I explained before. This is why the weak linking of the system's malloc is useless for experienced programmers who care about portability. (Since you asked: My valloc-uses-sbrk-directly demonstration was under Linux, exactly as I said; specifically, Debian. Are you really so naive as to think that all the Linux functions are listed in the manual?) ---D. J. Bernstein, Associate Professor, Department of Mathematics, Statistics, and Computer Science, University of Illinois at Chicago