From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,cd5214d1490fdb48,start X-Google-Attributes: gidfee84,public X-Google-ArrivalTime: 1994-07-18 16:41:19 PST Path: bga.com!news.sprintlink.net!hookup!swrinde!howland.reston.ans.net!vixen.cso.uiuc.edu!peltz From: peltz@cerl.uiuc.edu (Steve Peltz) Newsgroups: comp.unix.osf.osf1 Subject: mmap swapping bug Date: 18 Jul 1994 23:39:31 GMT Organization: CERL - University of Illinois at Urbana-Champaign Message-ID: <30f3rj$l50@vixen.cso.uiuc.edu> NNTP-Posting-Host: unicorn.cerl.uiuc.edu I posted this to vmsnet.alpha, before I found this newsgroup - since I have some modified info on this problem, I'll just post it here instead. I'm doing an mmap() to create a large (in this case, I believe it was 16M) shared memory segment - actually, two small (1M each) and one large. The only one that is actively being shared is one of the smaller ones, the larger one needs to be shareable in the future, but currently is not actually shared with anything else (except to look at it to figure out why the program died). What happens is that sometimes I get data at the wrong location, or possibly data that didn't get paged out properly (and thus when it gets paged in, I get an old copy). Sufficient (but not necessarily necessary) conditions for this to occur are: a) one process munching on disk (read() and write(), happens to be on the same drive as the mmapped files), and transferring all data through one of the small shared segments; b) a second process transferring data between the large shared segment and the disk process shared segment; c) the second process also doing lots of transfers back and forth between the third shared segment (the small one, not actually shared by anything else), and also doing random accesses of various lengths on all three shared segments; d) second process has timer interrupts going off every few milliseconds, and disk process also delivers signals to it; it is also reading the system clock "often" using getclock() (between setting the timer and reading the system clock, somewhere around 15K system calls per second). It is difficult to figure out exactly what happens, as this is a real-time event-driven program, but the best indication was one where 7 out of 8 pages were incorrect (specifically, pages 2E8-2EC and 2EE-2EF had the wrong data in them). The same data existed on page 305, offset 980 (which seems unlikely to have anything to do with it - data gets copied around occasionally, and the area where the damage occurred could have been the original location). Changing the large segment to be simple malloc'ed memory made the program work flawlessly, getting through a sequence of operations 10 times that previously had killed it every single time during the first or second pass; thus I've fairly well eliminated any possible problems in my code (since then, I've had it running for a total of about 60 hours with no problems evident). As soon as the person responsible for the machine gets back so we can install the realtime library so I can try mlock() on the segment, I'll try that - I'm reasonably certain that will solve the problem. However, I shouldn't have to mlock it in order to get correct results.