bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Strange error with cat (coreutils 4.5.2) on HP/UX


From: Petter Reinholdtsen
Subject: Re: Strange error with cat (coreutils 4.5.2) on HP/UX
Date: 13 Oct 2002 00:36:00 +0200
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/21.2

[Petter Reinholdtsen]
> I get the message 'cat: memory exhausted' when trying to run 'cat' on
> a big file across rsh to a HP/UX box.  The problem goes away when I
> try to do this in an interactive shell, or if I pipe the output from
> cat through dd:

I've tracked it down to a problem with fstat()/st_blksize when stdout
is sent through rsh.  I used this code to test:

  #include <stdio.h>
  #include <unistd.h>
  #include <sys/types.h>
  #include <sys/stat.h>
  int main(int argc, char *argv[]) {
     struct stat stat_buf;
     fstat(STDOUT_FILENO, &stat_buf);
     printf("st_blksize=%d(0x%x) high=%d low=%d\n", stat_buf.st_blksize,
            stat_buf.st_blksize >> 16,
            stat_buf.st_blksize & 0xffff);
     return 0;
  }

When I run it using an interactive shell on the HP/UX box:

  st_blksize=65536(0x10000) high=1 low=0

If I run it using 'rsh host testprog', the output is worse:

  st_blksize=2147421096(0x7fff0ba8) high=32767 low=2984

If I instead use dd in front (rsh snipe "/tmp/foo |dd"), I get this:

  st_blksize=8192(0x2000) high=0 low=8192'.

Perhaps the code in cat.c should check for insanely large values, and
not try to call xmalloc() with any large number?

Here is a stupid patch to fix the problem.  I'm not sure if this is
the right fix, but at least GNU cat works again on HP/UX.

diff -ur src-4.5.2/src/cat.c src-4.5.2-local/src/cat.c
--- src-4.5.2/src/cat.c 2002-09-29 23:25:03.000000000 +0200
+++ src-4.5.2-local/src/cat.c   2002-10-13 00:32:51.000000000 +0200
@@ -804,6 +804,10 @@
         --version, or --help) were specified, use `cat', otherwise use
         `simple_cat'.  */

+      /* Special case for HP/UX 11.00 */
+      if (outsize > 0x20000) /* Avoid xmalloc() on very huge numbers */
+          outsize = DEV_BSIZE;
+
       if (options == 0)
        {
          insize = max (insize, outsize);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]