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

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

Re: [gawk-stable] bug: fatal error when getline from directory


From: Paolo
Subject: Re: [gawk-stable] bug: fatal error when getline from directory
Date: Fri, 9 Jan 2009 23:40:14 +0100
User-agent: Mutt/1.3.28i

On Tue, Jan 06, 2009 at 07:30:44AM +0200, Aharon Robbins wrote:
> From: "Andrew J. Schorr" <address@hidden>
...
> > On Mon, Jan 05, 2009 at 11:27:40PM +0100, Paolo wrote:
> > > pls see attached diffs, it's just a POC for '/dir/' extension - I 
...
> Hmmm, my first thought was that this could be implemented as
> an extension using the register_open_hook feature (the same
...
> Yeah, I'd rather see this kind of thing be done with the open hook.

dunno much the code but tend to agree with both :)

> I tend to think that reading a directory should return a record with
> two fields: the inode number and the filename, and not just the filename.

hm, inode is fs-specific stuff, I'd rather KISS and return just the entry
name, then script can/should check for that thing's properties. Instead of
inode I thought of [dspcf] flag, but again, better stat()ing it later.
Also, note I intentionally bypassed RS/FS matcher, leaving such operation
to a later step. Although not necessary, sounds cleaner to me.
 
> While Paolo's original diff is straightforward, I'd prefer not to
> include it as it's feature creep; I'd rather beef up the infrastructure
> to support doing this kind of thing as an extension.

agreed.

Note there's a problem with my hack, in that iop_open() won't opendir() 
again, since it calls spec_setup() instead of reallocating iop, which is
flagged INTERNAL|NO_FREE. 

But seems there's a deeper problem with all such specfd stuff, eg:

$./gawk 'BEGIN {
  r=1; j=8; s="/inet/tcp/9999/comix/9809"
  while (j!=0 && r==1) {
    j--; r=getline x < s; print "\tr: "r"\tx: "x"\tERRNO: "ERRNO
  }
  r=close(s); print "\tclose: "r"\tERRNO: "ERRNO
  r=1
  while (r==1) {
    r=getline x < "/inet/tcp/9999/comix/9808"
    print "\tr: "r"\tx: "x"\tERRNO: "ERRNO
  }
}' 2>/dev/null
        r: 1    x: 1    ERRNO: 0
        r: 1    x: 2    ERRNO: 0
        r: 1    x: 3    ERRNO: 0
        r: 0    x: 3    ERRNO: 0
        close: 0        ERRNO: 0
        r: 1    x: 1    ERRNO: 0
        r: 1    x: 2    ERRNO: 0
        r: 1    x: 3    ERRNO: 0
        r: 1    x:      ERRNO: 0
        r: 1    x:      ERRNO: 0
        r: -1   x:      ERRNO: Bad file descriptor

where on node 'comix' I setup 2 instances of socket(1), like
$ socket -qbsl -p "echo 1;echo 2; echo 3" 9809
$ socket -qbsl -p "echo 4;echo 5; echo 6" 9808  
which shows 2 problems:

1. asymmetric behaviour on EOF
2. re-use of same socket, despite (implicit) close() of the 1st and, 
   anyway, explicit redirection from another port (expected output was 
   4 5 6)

Why iop for such specfd are kept around & re-used? I tried to make them
go away by not flagging'em NO_FREE and INTERNAL, but then iop_close() 
yields an exception on free(iop) - clearly a too dumb attempt :P


thx
-- 
 paolo
 
 GPG/PGP id:0x3A47DE45  - B5F9 AAA0 44BD 2B63 81E0  971F C6C0 0B87 3A47 DE45
 - 9/11: the outrageous deception & coverup: http://journalof911studies.com -




reply via email to

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