Bug 47504 - read/write -1 bytes
read/write -1 bytes
Status: CLOSED DEFERRED
Product: Red Hat Raw Hide
Classification: Retired
Component: rpm (Show other bugs)
1.0
All Linux
medium Severity medium
: ---
: ---
Assigned To: Jeff Johnson
David Lawrence
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2001-07-05 15:41 EDT by Nathan Owen
Modified: 2007-04-18 12:34 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2001-08-01 17:45:42 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
this is the output from rpm -qp ~/rpms/sed-3.02-9.src.rpm --rpmiodebug (5.34 KB, text/plain)
2001-07-05 18:01 EDT, Nathan Owen
no flags Details

  None (edit)
Description Red Hat Bugzilla 2001-07-05 15:41:45 EDT
Description of Problem:
When rpm reads or writes to/from a package it will always pass the value -1
to read or write as the (unsigned) number of bytes to read/write. On linux
this appears to work (accidentaly I would hope) but solaris to catches this
and returns an error (errno 22, Invalid Argument).

How Reproducible:
rpm -qp somepackage.rpm
rpm -ba somepackage.spec
This will work on linux, but fail on solaris

Additional Information:
I think this is because neither fd->contentLength nor fd->bytesRemain is
ever set to anything but -1 before fdRead or fdWrite is called.

It appears to work if the sign bit of fd->bytesRemain is masked out, but
this is a hack and I am working on a patch with a "better" way to fix this.
Comment 1 Red Hat Bugzilla 2001-07-05 15:50:56 EDT
Can you append the output of an example with --rpmiodebug set?
That should be enough for me to figger what's up and get a fix
in place, as the rpmio code is guaranteed to make your head hurt :-)
Comment 2 Red Hat Bugzilla 2001-07-05 18:01:27 EDT
Created attachment 22827 [details]
this is the output from rpm -qp ~/rpms/sed-3.02-9.src.rpm --rpmiodebug
Comment 3 Red Hat Bugzilla 2001-07-08 11:41:31 EDT
Here's the relevant piece:

=> Ferror(2f6d0) rc 0  | UFD 6 fp 0
==> Fileno(2f6d0) rc 6  | UFD 6 fp 0
==>     fdRead(2f6d0,efffe190,96) rc -1         | UFD 6 fp 0
*** read: rc -1 errno 22 Invalid argument ""
error: read failed: Invalid argument (22)
==> Fclose(2f6d0)       | UFD 6 fp

Here's the code:
    rc = read(fdFileno(fd), buf, (count > fd->bytesRemain ? fd->bytesRemain :
count));

The underlying issue is multiplexing mutiple I/O streams across an open file
descriptor of, say, a persistent HTTP/1.1 connection, so fdRead() needs to
simulate EOF based on ContentLength:.  value, if present.

So the problem seems to be with the ssize_t prototype being treated
differently on Solaris in read(2) (from rpmio/rpmio_internal.h)
   ssize_t     bytesRemain;
   ssize_t     contentLength;

Ah yes, the comparison on linux is (casts added for clatity) unsigned
	((size_t)count) > ((ssize_t)fd->bytes_remain)

so the problem is (I predict) that size_t is int, not unsigned, on
Solaris. If that's the case, I can get an unsigned cast in place
throughout rpmio comparisons in a jiffy.
Comment 4 Red Hat Bugzilla 2001-07-16 12:12:09 EDT
Well a size_t is being defined as an unsigned int in sys/types.h, and when I
tried it that cast had no effect.

after rereading the manpage for read I noticed this line:
     If the value of nbyte is greater than SSIZE_MAX, the  result
     is implementation-dependent.

It looks to me like the implementation in solaris 2.6 just considers this to be
an error.
Comment 5 Red Hat Bugzilla 2001-08-01 16:55:05 EDT
Nathan-

Since we use rpm on a lot of platforms (including Solaris) too, I just built rpm
from CVS
on a Solaris 2.8 box, and I can't reproduce this problem.  Do you have Solaris
2.8,
and is the problem happening there too?  Other than some build issues, rpm from
CVS has worked for the few tests I've tried.

I tried building rpm from CVS on 2.6, but the db-3.3.11 build (part of rpm)
causes
Solaris' `ar' command to core dump, and I can't take any of our 2.6 systems down
to apply the latest patch bundle to see if the problem goes away.
Comment 6 Red Hat Bugzilla 2001-08-01 17:45:37 EDT
Unfortunately I only have access to 2.6 systems here so I can't say anything
about 2.7 or 2.8. 

I cannot reach the CVS server from work so I've been working with the rawhide
packages and building them with the GNUpro tools so I don't know whether the
patches from Sun would fix your problem.

FWIW I'm using GNU ar 2.9-gnupro-99r1

Other than this one, I have not found any problems with rpms behavior beyond
some build issues (most of them have already gotten into CVS). I have a rather
trivial patch that fixes this problem if you get past your build problem.
Comment 7 Red Hat Bugzilla 2001-08-04 14:36:53 EDT
So far this problem is localized to a single solaris 2.6 box (sorry Nathan),
I'm gonna defer this problem until someone tells me what the right
thing to do is.

Note You need to log in before you can comment on or make changes to this bug.