Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* mmap swapping bug
@ 1994-07-18 23:39 Steve Peltz
  0 siblings, 0 replies; only message in thread
From: Steve Peltz @ 1994-07-18 23:39 UTC (permalink / raw)


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.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1994-07-18 23:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1994-07-18 23:39 mmap swapping bug Steve Peltz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox