From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/336 Path: news.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: New daily reports - debugging alloc.c et al Date: Sat, 6 Aug 2011 16:34:33 +0200 Message-ID: <20110806143433.GV29562@port70.net> References: <4E39C84F.8060705@gmail.com> <20110803224651.GB11437@openwall.com> <4E3A79B2.8090204@gmail.com> <4E3B331E.7050502@gmail.com> <4E3CC5AC.3070404@gmail.com> <20110806111505.GS29562@port70.net> <20110806115014.GT29562@port70.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="tT3UgwmDxwvOMqfu" X-Trace: dough.gmane.org 1312641290 30450 80.91.229.12 (6 Aug 2011 14:34:50 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 6 Aug 2011 14:34:50 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-337-gllmg-musl=m.gmane.org@lists.openwall.com Sat Aug 06 16:34:46 2011 Return-path: Envelope-to: gllmg-musl@lo.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by lo.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1Qphxe-0004xk-2H for gllmg-musl@lo.gmane.org; Sat, 06 Aug 2011 16:34:46 +0200 Original-Received: (qmail 3111 invoked by uid 550); 6 Aug 2011 14:34:45 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 3103 invoked from network); 6 Aug 2011 14:34:45 -0000 Content-Disposition: inline In-Reply-To: <20110806115014.GT29562@port70.net> User-Agent: Mutt/1.5.20 (2009-06-14) Xref: news.gmane.org gmane.linux.lib.musl.general:336 Archived-At: --tT3UgwmDxwvOMqfu Content-Type: text/plain; charset=us-ascii Content-Disposition: inline * Szabolcs Nagy [2011-08-06 13:50:15 +0200]: > interestingly /proc/self/smaps does not seem to > list all the successful mmaps.. i wonder why but this is false, i failed to read smaps entirely as discussed on irc here is a code that can fill up the vm quickly and painlessly --tT3UgwmDxwvOMqfu Content-Type: text/x-csrc; charset=us-ascii Content-Disposition: attachment; filename="vmfill.c" #include #include #include #include #include #include #ifndef PAGE_SIZE #define PAGE_SIZE sysconf(_SC_PAGE_SIZE) #endif static void printvm() { int fd = open("/proc/self/smaps", O_RDONLY); char buf[4096]; int n; printf("/proc/self/smaps:\n"); fflush(stdout); while ((n = read(fd, buf, sizeof buf)) > 0) write(1, buf, n); close(fd); } static size_t mmapmax(int fd, void **p) { size_t i,j,n=0; for (i=j=SIZE_MAX/2; i>0; i/=2) { if ((*p=mmap(NULL, j, PROT_NONE, MAP_PRIVATE, fd, 0)) == MAP_FAILED) j -= i/2; else { n = j; munmap(*p, n); j += i/2; } } if (n && (*p=mmap(NULL, n, PROT_NONE, MAP_PRIVATE, fd, 0)) == MAP_FAILED) { fprintf(stderr, "failed to mmap the same amount again.\n"); exit(1); } return n; } int main(int argc, char *argv[]) { const int fd = open("/dev/zero", O_RDWR); void *p[100]; size_t n[100]; size_t sum = 0; int i; int vmmaps = 0; if (argc == 2 && argv[1][0]=='-' && argv[1][1]=='v') vmmaps = 1; for (i=0; i