From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Mon, 2 Jun 2014 23:00:15 -0700 From: Anthony Martin To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Message-ID: <20140603060015.GA28564@dinah> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [9fans] kernel bug Topicbox-Message-UUID: f4c20e18-ead8-11e9-9d60-3106f5b1d025 Yoann Padioleau once said: > in the newseg() function there is: > > [...] > > I think it should be > if(mapsize > (SEGMAPSIZE)) > mapsize = SEGMAPSIZE; Yes, you're correct. The code allows the creation of a segment VM map with more than SEGMAPSIZE Ptes. Personally, I'd remove the check entirely along with the optimization of doubling the segment size, perhaps moving it to ibrk. I think it's more likely that the segment will grow if brk is called at least once. Anthony P.S. It looks like this is a 15 year old bug: 1998/0916/sys/src/9/port/segment.c:62,67 - 1998/0919/sys/src/9/port/segment.c:62,70 mapsize = ROUND(size, PTEPERTAB)/PTEPERTAB; if(mapsize > nelem(s->ssegmap)){ + mapsize *= 2; + if(mapsize > (SEGMAPSIZE*PTEPERTAB)) + mapsize = (SEGMAPSIZE*PTEPERTAB); s->map = smalloc(mapsize*sizeof(Pte*)); s->mapsize = mapsize; }