Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
* incorrect lseek() function in glibc-2.0.7
@ 1999-03-18  1:13 Michal Jaegermann
  1999-03-19  6:12 ` Richard Henderson
  0 siblings, 1 reply; 5+ messages in thread
From: Michal Jaegermann @ 1999-03-18  1:13 UTC (permalink / raw)
  To: drepper; +Cc: axp-list, bj0rn


lseek from glibc-2.0.7 is broken on Alpha.  It is documented to
have the following prototype:

   off_t lseek(int fildes, off_t offset, int whence);

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
....
where the program attempts to seek to a location with a module
information in a memory. 18446739675790475552 happens to be
in hex 0xfffffc0007988120 and the return value is 0x7988120
so it is returned as 'int' and not 'off_t' - which, at least on
Alpha, are of different sizes.

What is more lseek() does not seem to be searching to a required
location as an attempt to read from there results in obviously
bogus values (all zeros).

  Michal Jaegermann,
  michal@harddata.com


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: incorrect lseek() function in glibc-2.0.7
  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
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Henderson @ 1999-03-19  6:12 UTC (permalink / raw)
  To: axp-list, drepper; +Cc: bj0rn

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.

I see off_t declared properly in libc and kernel source,
so the problem isn't what you're describing exactly.


r~


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: incorrect lseek() function in glibc-2.0.7
  1999-03-19  6:12 ` Richard Henderson
@ 1999-03-19  6:48   ` Michal Jaegermann
  1999-03-19  7:16     ` Richard Henderson
  0 siblings, 1 reply; 5+ messages in thread
From: Michal Jaegermann @ 1999-03-19  6:48 UTC (permalink / raw)
  To: axp-list; +Cc: drepper, bj0rn, rth

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.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: incorrect lseek() function in glibc-2.0.7
  1999-03-19  6:48   ` Michal Jaegermann
@ 1999-03-19  7:16     ` Richard Henderson
  1999-03-28  2:05       ` Michal Jaegermann
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Henderson @ 1999-03-19  7:16 UTC (permalink / raw)
  To: Michal Jaegermann, axp-list; +Cc: drepper, bj0rn

On Thu, Mar 18, 1999 at 11:48:21PM -0700, Michal Jaegermann wrote:
> ... from /dev/kmem a module information when in use with one of
> 2.0 kernels.

Somehow I missed this `2.0' thing before.  I should have wondered
why modutils was touching kmem on 2.2, but...

With stock 2.0.x, the problem is in drivers/char/mem.c --

  static int memory_lseek(struct inode * inode, struct file * file,
			  off_t offset, int orig)

There are patches floating about to change the internal fs type
to `long' for 2.0.  I actually thought these were distributed
with eg RH kernels.  Is this a roll-yer-own?


r~


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: incorrect lseek() function in glibc-2.0.7
  1999-03-19  7:16     ` Richard Henderson
@ 1999-03-28  2:05       ` Michal Jaegermann
  0 siblings, 0 replies; 5+ messages in thread
From: Michal Jaegermann @ 1999-03-28  2:05 UTC (permalink / raw)
  To: axp-list

Richard,
in a response to my complaints about lseek you wrote the following:
> 
> With stock 2.0.x, the problem is in drivers/char/mem.c --
> 
>   static int memory_lseek(struct inode * inode, struct file * file,
> 			  off_t offset, int orig)
> 
> There are patches floating about to change the internal fs type
> to `long' for 2.0.  I actually thought these were distributed
> with eg RH kernels.

Well, I had at last a closer look at kernel-source-2.0.36-3.alpha.rpm
which is the latest one in updates to 5.2 from Red Hat.  I see there
the following:

static int mem_lseek(struct inode * inode, struct file * file,
                     off_t offset, int orig)

which does not seem to be much different from what you wrote and
what is in original sources. :-) If there are any patches floating
around for that problem I am not aware of them.  I tried to hack
kernel sources a bit.  This creates slight problems elsewhere and
would require quite a bit of an intervention to make it clean
(or I am doing something wrong).  In any case - this did not help
very much as glibc seems to have its own ideas.  I got a different
error message but that was about it.

If I am missing something big here I would like to know.

 Michal


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~1999-03-28  2:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
1999-03-19  7:16     ` Richard Henderson
1999-03-28  2:05       ` Michal Jaegermann

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