From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 18114 invoked from network); 19 Mar 1999 06:59:23 -0000 Received: from mail.redhat.com (199.183.24.239) by lists.redhat.com with SMTP; 19 Mar 1999 06:59:23 -0000 Received: from ellpspace.math.ualberta.ca (michal@ellpspace.math.ualberta.ca [129.128.88.19]) by mail.redhat.com (8.8.7/8.8.7) with ESMTP id BAA31249 for ; Fri, 19 Mar 1999 01:48:34 -0500 Received: (from michal@localhost) by ellpspace.math.ualberta.ca (8.8.8/8.8.8) id XAA03361; Thu, 18 Mar 1999 23:48:21 -0700 From: Michal Jaegermann Message-Id: <199903190648.XAA03361@ellpspace.math.ualberta.ca> Subject: Re: incorrect lseek() function in glibc-2.0.7 To: axp-list@redhat.com Date: Thu, 18 Mar 1999 23:48:21 -0700 (MST) Cc: drepper@cygnus.com, bj0rn@blox.se, rth@twiddle.net In-Reply-To: <19990318221222.A24426@twiddle.net> from "Richard Henderson" at Mar 18, 99 10:12:22 pm Content-Type: text Richard Henderson wrote: > > On Wed, Mar 17, 1999 at 06:13:35PM -0700, Michal Jaegermann wrote: > > Here is a fragment of a trace from a new version of 'lsmod': > > .... > > open("/dev/kmem", O_RDONLY) = 4 > > lseek(4, 18446739675790475552, SEEK_SET) = 127435040 > > You'll have to come up with better evidence than that. > Strace is so notoriously buggy I'll believe that's doing > the wrong thing before anything else. While debugging I actually modified sources of 'lsmod' around the code in question and printed all values in a program, not from strace and not even from gdb. Results were exactly the same as above. Better? Hex values I quoted in my original message were from this printout. Also the code in question, which really comes from modutils-2.2.2-pre1 (or from modutils-2.2.2-pre2, for that matter), attempts to read from /dev/kmem a module information when in use with one of 2.0 kernels. After this 'lseek' all values read come as 0. This does not look like a correct position in /dev/kmem but I am not sure how to test precisely this. In modutils-2.2.2-pre2 Bjorn changed the code to go roughly like that (previous version was comparing with -1): off_t offset; .... if (!(lseek(handle, offset, SEEK_SET) == offset)) { /* some other stuff */ exit_with_error(); } This always triggers and one is getting a bogus error printed because lseek does not really fail but returned value is wrong; so errno was set by some earlier, not related, stuff. > I see off_t declared properly in libc and kernel source, > so the problem isn't what you're describing exactly. There is no problem with declarations. They are correct. Something in the code is bogus. Note that lseek() does not use sys_lseek(); at least not directly. I guess that because most of the time one is using lseek on "disk files" then offset values which do not fit in 32-bits are rarely used and the error went unnoticed for quite a while. Michal p.s. an information which 'lsmod' tries to grab from /dev/kmem is really provided by 'cat /proc/modules' but that is beside the point.