bug-gdb
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

libmmalloc chokes on /dev/zero


From: Scott Pakin
Subject: libmmalloc chokes on /dev/zero
Date: Tue, 05 Mar 2002 13:52:58 -0700
User-agent: Mozilla/5.0 (X11; U; Linux 2.4.2-2 i686; en-US; 0.7) Gecko/20010316

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]