From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11100 invoked by alias); 23 Mar 2002 19:54:48 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 11093 invoked from network); 23 Mar 2002 19:54:46 -0000 Received: from unknown (HELO localhost.redhat.com) (24.112.240.27) by 209.249.29.67 with SMTP; 23 Mar 2002 19:54:46 -0000 Received: from cygnus.com (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id 53ECC3DCE; Sat, 23 Mar 2002 14:54:34 -0500 (EST) Message-ID: <3C9CDD7A.1080302@cygnus.com> Date: Sat, 23 Mar 2002 11:54:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:0.9.8) Gecko/20020210 X-Accept-Language: en-us MIME-Version: 1.0 To: Scott Pakin Cc: gdb-patches@sources.redhat.com Subject: Re: PATCH: Make libmmalloc work properly with /dev/zero References: <3C854268.2080508@uiuc.edu> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2002-03/txt/msg00447.txt.bz2 > I just tried using libmmalloc for the first time, and I was unable to > get it to work when allocating memory from /dev/zero (e.g., by using > "mmalloc_attach (-1, NULL)" to mmap() it). libmmalloc bus errors when > it tries to write to the allocated region. The library works fine > when I use an ordinary file, however. > > I'm using the libmmalloc.a that comes with gdb-5.1, and I'm running > under Linux 2.4.2. /dev/zero has 0666 permissions. > > I believe the bug is that libmmalloc always mmap()s files with > MAP_SHARED, but it ought to map /dev/zero with MAP_PRIVATE, because > /dev/zero really isn't writable. Attached below is a patch to > mmap-sup.c that makes mmalloc conditionally use one of MAP_SHARED or > MAP_PRIVATE, based on whether or not the library explicitly opened > /dev/zero. > > Of course, if there's some subtle reason the code was written the way > it was -- or if I'm doing something egregiously wrong -- please let me > know. Fred's ok with this patch. However, I can't get it to apply - something ate something while it was in transit? Perhaphs post it as a mime attachment? I'll also need a ChangeLog entry. nice catch, Andrew