This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: Make libmmalloc work properly with /dev/zero


> 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




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]