Article View: gnu.gdb.bug
Article #2581libmmalloc chokes on /dev/zero
From: Scott Pakin
Date: Tue, 05 Mar 2002 20:52
Date: Tue, 05 Mar 2002 20:52
20 lines
2199 bytes
2199 bytes
When I use libmmalloc to allocate 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 mmalloc 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 memory with MAP_SHARED, but it ought to map /dev/zero with MAP_PRIVATE. A quick search-and-replace does seem to fix the problem. I'm guessing that a clean solution (selecting MAP_SHARED or MAP_PRIVATE based on whether /dev/zero is being used) should take <10 lines of code. However, before doing this and submitting a patch file, I was wondering if there's some subtle reason the code was written the way it was -- or if I'm the only one who's had trouble with /dev/zero. Comments? -- Scott
Technical Details
Message-ID:
<3C85302A.2020503@uiuc.edu>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!torn!news-out.cwix.com!newsfeed.cwix.com!nntp.abs.net!uunet!dca.uu.net!ash.uu.net!spool0901.news.uu.net!wendy-fate.uu.net!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f5053,d8638eaaf54758b6,start X-Google-Attributes: gidf5053,public X-Google-ArrivalTime: 2002-03-05 12:53:05 PST x-uunet-gateway: mr0.ash.ops.us.uu.net from bug-gdb to gnu.gdb.bug; Tue, 5 Mar 2002 20:53:03 GMT Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!torn!news-out.cwix.com!newsfeed.cwix.com!nntp.abs.net!uunet!dca.uu.net!ash.uu.net!spool0901.news.uu.net!wendy-fate.uu.net!not-for-mail From: pakin@uiuc.edu (Scott Pakin) Subject: libmmalloc chokes on /dev/zero Date: Tue, 05 Mar 2002 13:52:58 -0700 Organization: University of Illinois at Urbana-Champaign Message-ID: <3C85302A.2020503@uiuc.edu> NNTP-Posting-Host: antero.c3.lanl.gov Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: pith.uoregon.edu 1015361583 26458 128.165.20.177 (5 Mar 2002 20:53:03 GMT) X-Complaints-To: news@news.uoregon.edu NNTP-Posting-Date: Tue, 5 Mar 2002 20:53:03 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; U; Linux 2.4.2-2 i686; en-US; 0.7) Gecko/20010316 X-Accept-Language: en Approved: bug-gdb-request@mail.gnu.org Newsgroups: gnu.gdb.bug Sender: bug-gdb-request@mail.gnu.org Lines: 21