mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Earl Chew <echew@ixiacom.com>
To: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Advice for 32 bit compatibility problem with pread(2) on x86_64
Date: Tue, 17 Jan 2012 17:36:31 -0800	[thread overview]
Message-ID: <4F16221F.6060304@ixiacom.com> (raw)

pread(2) in 32 bit mode (x86_64) seems to leave the file in a crummy state
causing the next pread(2) to fail.

I'd like a hint as to where to look for the root cause.

I'm running:

	Linux ixbu-lnxbld-vm 2.6.32-33-generic #72-Ubuntu SMP Fri Jul 29 21:07:13 UTC 2011 x86_64 GNU/Linux

Here is the test program (use syscall() to try give glibc an alibi):

> #include <fcntl.h>
> #include <sys/syscall.h>
> 
> 
> int main()
> {
>     char buf[8192];
>     int fd = open("/proc/self/maps", O_RDONLY);
> 
>     syscall(SYS_pread64, fd, buf, 8192, 0, 0);
>     syscall(SYS_pread64, fd, buf, 8192, 0, 0);
> 
>     return 0;
> }

Compiling with -m32 and running with strace(), the 2nd pread() return zero !

> open("/proc/self/maps", O_RDONLY)       = 3
> pread64(3, "08048000-08049000 r-xp 00000000 "..., 8192, 0) = 1189
> pread64(3, "", 8192, 0)                 = 0

Compiling for 64 bit I get the expected:

> open("/proc/self/maps", O_RDONLY)       = 3
> pread(3, "00400000-00401000 r-xp 00000000 "..., 8192, 0) = 1332
> pread(3, "00400000-00401000 r-xp 00000000 "..., 8192, 0) = 1332

Huh ?

Earl



                 reply	other threads:[~2012-01-18  1:37 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=4F16221F.6060304@ixiacom.com \
    --to=echew@ixiacom.com \
    --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

Powered by JetHome