This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: PATCH: Make libmmalloc work properly with /dev/zero
- From: Andrew Cagney <ac131313 at cygnus dot com>
- To: Scott Pakin <pakin at uiuc dot edu>
- Cc: gdb-patches at sources dot redhat dot com
- Date: Sat, 23 Mar 2002 14:54:34 -0500
- Subject: Re: PATCH: Make libmmalloc work properly with /dev/zero
- References: <3C854268.2080508@uiuc.edu>
> 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