From: Sami Farin <safari-kernel@safari.iki.fi>
To: Linux kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: 2.6.28.4 regression: mmap fails if mlockall used
Date: Sun, 8 Feb 2009 12:52:22 +0200 [thread overview]
Message-ID: <20090208105222.hj7zhcyxyqfjeobt@m.safari.iki.fi> (raw)
[-- Attachment #1: Type: text/plain, Size: 782 bytes --]
2.6.28.2 + gcc-4.3.2-7 works.
2.6.28.4 + gcc-4.4.0-0.16 does not work.
I run x86_64 SMP kernel.
# strace ./a.out ntp
12:10:14.780726 mmap(NULL, 2147624, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = -1 EFAULT (Bad address) <0.000038>
12:10:14.780809 close(3) = 0 <0.000012>
12:10:14.780856 munmap(0x7f3476e0d000, 421232) = 0 <0.000145>
12:10:14.781054 write(2, "./a.out: getpwnam failed: Success\n"..., 34./a.out: getpwnam failed: Success
) = 34 <0.000015>
I can do malloc(3000000), then mmap call is
12:50:20.694207 mmap(NULL, 3002368, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f8a8d16b000 <0.003078>
--
"When playing Russian roulette, the fact that the first shot
got off safely is little comfort for the next." - Richard Feynman
[-- Attachment #2: getpw.c --]
[-- Type: text/plain, Size: 645 bytes --]
#include <string.h>
#include <errno.h>
#include <stdio.h>
#include <sys/types.h>
#include <pwd.h>
#include <sys/mman.h>
int main(int argc, char *argv[])
{
struct passwd *pw;
if (mlockall(MCL_CURRENT | MCL_FUTURE) == -1) {
fprintf(stderr, "%s: mlockall failed: %s\n",
argv[0], strerror(errno));
}
if (argc != 2) return 1;
errno = 0;
pw = getpwnam(argv[1]);
if (pw == NULL) {
fprintf(stderr, "%s: getpwnam failed: %s\n",
argv[0], strerror(errno));
return 1;
}
fprintf(stdout, "uid=%u gid=%u\n",
(unsigned int)pw->pw_uid, (unsigned int)pw->pw_gid);
fflush(stdout);
return 0;
}
next reply other threads:[~2009-02-08 10:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-08 10:52 Sami Farin [this message]
2009-02-08 18:25 ` 2.6.28.4 regression: mmap fails if mlockall used Hugh Dickins
2009-02-08 19:23 ` Sami Farin
2009-02-08 20:56 ` Hugh Dickins
2009-02-11 6:55 ` Doug Bazarnic
2009-02-11 18:34 ` Hugh Dickins
2009-02-11 21:56 ` Rafael J. Wysocki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090208105222.hj7zhcyxyqfjeobt@m.safari.iki.fi \
--to=safari-kernel@safari.iki.fi \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).