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

Bug#677704: unusable multiarch (triggers "Dynamic MMap ran out of room" error)



On Sat, Jun 16, 2012 at 12:53:43PM +0200, Robert Millan wrote:
> clone 677704 -1
> retitle -1 missing mremap() implementation
> severity -1 wishlist
> reassign -1 kfreebsd-9
> forwarded -1 http://www.freebsd.org/cgi/query-pr.cgi?pr=59912
> block 677704 by -1
> thanks
> 
> 2012/6/16 Julian Andres Klode <jak@debian.org>:
> > On Sat, Jun 16, 2012 at 12:09:06PM +0200, Robert Millan wrote:
> >> Package: apt
> >> Version: 0.9.6
> >> Severity: important
> >> User: debian-bsd@lists.debian.org
> >> Usertags: kfreebsd
> >>
> >> Tried increasing this limit, with no improvement.  I also wonder how is
> >> libpgocaml-ocaml-dev related to this ...
> >
> > Yes, we don't have mremap() on kFreeBSD, which we use for resizing. This
> > could be fixed by rewriting the mremap() part to use munmap() and mmap()
> > instead of mremap(). I can't tell you why the limit increasing does not
> > help, though, someone else might know more.
> 
> Thanks.  Unfortunately I don't currently have time to work on this,
> but I'm adding a bug for mremap request as well...

The attached patch probably fixes this, although I did not test it
myself on kFreeBSD (but on Linux). And it's a bit hackish in my
opinion, but might be better than nothing.

-- 
Julian Andres Klode  - Debian Developer, Ubuntu Member

See http://wiki.debian.org/JulianAndresKlode and http://jak-linux.org/.
=== modified file 'apt-pkg/contrib/mmap.cc'
--- apt-pkg/contrib/mmap.cc	2012-05-21 17:12:25 +0000
+++ apt-pkg/contrib/mmap.cc	2012-06-16 12:11:16 +0000
@@ -248,12 +248,6 @@ DynamicMMap::DynamicMMap(unsigned long F
 	if (Grow == 0)
 		this->Flags &= ~Moveable;
 
-#ifndef __linux__
-	// kfreebsd doesn't have mremap, so we use the fallback
-	if ((this->Flags & Moveable) == Moveable)
-		this->Flags |= Fallback;
-#endif
-
 #ifdef _POSIX_MAPPED_FILES
 	if ((this->Flags & Fallback) != Fallback) {
 		// Set the permissions.
@@ -454,6 +448,18 @@ bool DynamicMMap::Grow() {
 
 		if(Base == MAP_FAILED)
 			return false;
+#elif  defined(_POSIX_MAPPED_FILES)
+		if (Fd != 0 && (Flags & Moveable) && SyncToFd == 0) {
+			/* Poor man's mremap. We need to restore iSize afterwards,
+			* as that is set by RawAllocate in DynamicMMap */
+			unsigned long iSizeO = iSize;
+			munmap(Base, WorkSpace);
+			if (Map(*Fd) == false)
+				return false;
+			iSize = iSizeO;
+		} else {
+			return false;
+		}
 #else
 		return false;
 #endif


Reply to: