Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Michal Jaegermann <michal@ellpspace.math.ualberta.ca>
To: axp-list@redhat.com
Cc: drepper@cygnus.com, bj0rn@blox.se, rth@twiddle.net
Subject: Re: incorrect lseek() function in glibc-2.0.7
Date: Thu, 18 Mar 1999 23:48:21 -0700 (MST)	[thread overview]
Message-ID: <199903190648.XAA03361@ellpspace.math.ualberta.ca> (raw)
In-Reply-To: <19990318221222.A24426@twiddle.net> from "Richard Henderson" at Mar 18, 99 10:12:22 pm

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.


  reply	other threads:[~1999-03-19  6:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-03-18  1:13 incorrect lseek() function in glibc-2.0.7 Michal Jaegermann
1999-03-19  6:12 ` Richard Henderson
1999-03-19  6:48   ` Michal Jaegermann [this message]
1999-03-19  7:16     ` Richard Henderson
1999-03-28  2:05       ` Michal Jaegermann
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox