Re: Memory lock problem in Linux

Harald Koenig (koenig@tat.physik.uni-tuebingen.de)
Thu, 16 Oct 1997 11:05:17 +0200


On Oct 15, Michael Champigny wrote:

> It looks like the mlockall call in Linux is broken, at least in the stock
> 2.0.30 production kernel. Try running this as root:
>
> #define _XOPEN_SOURCE
> #include <unistd.h>
> #include <stdio.h>
> #include <sys/mman.h>
>
> int main(void)
> {
> mlockall(MCL_CURRENT);
> printf("Do something...\n");
> exit(0);
> }
>
> You should get a seg fault. I've only tested this on Alpha, but I'm
> sure it's there for all architectures. Can someone fix this? It's
> keeping me from developing real-time apps in Linux. Richard Henderson,
> and others have a patch for this, (which works) but it's not in the
> production source tree yet. :-( Can someone create (or get) the patch
> and submit it to Linus?

I don't get a SEGV using x86 Linux-2.0.30, gcc-2.7.2.1 and libc.so.5.4.33.
here is the strace output:

personality(PER_LINUX) = 0
geteuid() = 0
getuid() = 0
getgid() = 0
getegid() = 0
mlockall(0x1, 0x8049550, 0, 0x40001fb0, 0x80483b8) = 0
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(4, 193), ...}) = 0
mmap(0, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40007000
ioctl(1, TCGETS, {B9600 opost isig icanon echo ...}) = 0
write(1, "Do something...\n", 16) = 16
_exit(0) = ?

Harald

--
All SCSI disks will from now on                     ___       _____
be required to send an email notice                0--,|    /OOOOOOO\
24 hours prior to complete hardware failure!      <_/  /  /OOOOOOOOOOO\
                                                    \  \/OOOOOOOOOOOOOOO\
                                                      \ OOOOOOOOOOOOOOOOO|//
Harald Koenig,                                         \/\/\/\/\/\/\/\/\/
Inst.f.Theoret.Astrophysik                              //  /     \\  \
koenig@tat.physik.uni-tuebingen.de                     ^^^^^       ^^^^^