All of lore.kernel.org
 help / color / mirror / Atom feed
* Advice for 32 bit compatibility problem with pread(2) on x86_64
@ 2012-01-18  1:36 Earl Chew
  0 siblings, 0 replies; only message in thread
From: Earl Chew @ 2012-01-18  1:36 UTC (permalink / raw)
  To: linux-kernel@vger.kernel.org

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



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

only message in thread, other threads:[~2012-01-18  1:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-18  1:36 Advice for 32 bit compatibility problem with pread(2) on x86_64 Earl Chew

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.