Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2001-08-24
01:25 • Ticket [417111ffff] error in "glob -type r *" status still Closed ... artifact: 161bd83da0 user: vincentdarley
01:25 • Closed ticket [417111ffff]. artifact: 0fde7eaf06 user: vincentdarley
2001-08-16
16:57 • Ticket [417111ffff]: 5 changes artifact: bf59788a12 user: dkf
15:57 • Ticket [417111ffff]: 5 changes artifact: c66d405ed3 user: vincentdarley
00:57 • Ticket [417111ffff]: 5 changes artifact: 93a9aca61c user: hobbs
00:44 • Ticket [417111ffff]: 5 changes artifact: 5a99efb9bf user: vincentdarley
2001-08-13
21:33 • Ticket [417111ffff]: 6 changes artifact: f9f7b0e8a5 user: dkf
20:44 • Ticket [417111ffff]: 5 changes artifact: 1e79c92843 user: hemanglavana
2001-08-10
15:18 • Ticket [417111ffff]: 5 changes artifact: ab8f3d7bc3 user: dkf
2001-08-09
00:33 • Add attachment panic.diff to ticket [417111ffff] artifact: 07fd699c9b user: vincentdarley
00:33 • Ticket [417111ffff] error in "glob -type r *" status still Open wi... artifact: a86e62bc4a user: vincentdarley
2001-08-07
07:25 • Ticket [417111ffff]: 6 changes artifact: 1aa35632eb user: hobbs
2001-04-19
01:18 • Ticket [417111ffff]: 2 changes artifact: f693835675 user: dgp
2001-04-18
17:03 • New ticket [417111ffff]. artifact: 75f0361953 user: hemanglavana

error in "glob -type r *"

Closed / Fixed417111ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 25 years ago
Descriptionplain2001-04-18 17:03:16
On solaris2.6 platform, if a directory contains a
softlink that refers
to a non-existant file, then the above glob command
results in
error/abort:

hlavana-u5:6> ls -l
total 16
-rw-r--r--   1 hlavana  eng8           0 Apr 18 10:00
junk
lrwxrwxrwx   1 hlavana  eng8           4 Apr 18 09:06
link -> junk
hlavana-u5:7> ~/sw/bin/tclsh8.3
% info patch
8.3.3
% glob -type r *
link junk
% file delete junk
% glob -type r *
stat failed on known file
Abort
hlavana-u5:8> 

Hemang.
dgp Ticket [417111ffff]: 2 changes [History diff]2001-04-19 01:18:12
hobbsplain2001-08-07 07:25:19
Logged In: YES 
user_id=72656

Verified on Linux.  The stat should be caught somehow 
internally.
vincentdarleyplain2001-08-09 00:33:13
File Added - 9378: panic.diff

Logged In: YES 
user_id=32170

This behaviour is clearly determined here in tclUnixFile.c:

    if (TclpStat(fname, &buf) != 0) {
panic("stat failed on known file");
    }

Perhaps a better solution to this would be that in the 
attached patch (which I should point out I have no way of 
testing at all).
dkfplain2001-08-10 15:18:54
Logged In: YES 
user_id=79902

The patch looks OK to me, though it is still possible for
the panic() to be invoked in an unfortunate way if a file
gets deleted between the readdir() and the TclpLstat(),
which could happen (for example) if the OS decided to switch
to another process when the stat() was performed.

All this leads me to ask whether panic() is really the right
behaviour here, or whether it would be better to just fail
that directory entry silently, pretending that it was never
there in the first place.  What is certain is that panic()
is not an appropriate response to a bad link!
hemanglavanaplain2001-08-13 20:44:54
Logged In: YES 
user_id=81875

I have verified the patch on solaris platform. It does not
abort anymore for the specific example I had submitted
earlier.  However, it does not return the name of link file.
This means that I cannot use "glob -type r *" command to
find and delete all files of tye link. Also, "file exists
link" returns 0 even though the link name exists - I think
it should return 1.

lavana@zodiac: [5] ls -l
total 8
-rw-r--r--   1 lavana   cbltesters      0 Aug 11 12:13 abc
lrwxrwxrwx   1 lavana   cbltesters      4 Aug 11 12:06 link
-> junk
lavana@zodiac: [6] tclsh8.4
% glob -type r *
abc
% glob *
link abc
% file exists link
0
% exit
lavana@zodiac: [7]
dkfplain2001-08-13 21:33:08
Logged In: YES 
user_id=79902

Of course you can't use [glob -type r *] to find all files
of type link; it gives a list of readable files, and links
without a target are not readable in any normal sense.  If
you want links, use [glob -type l *] (if I'm not greatly
mistaken...)

The real question here is what do we want the semantics of
broken links to be?  One possibility is that they are
filenames without a file to go with them...
vincentdarleyplain2001-08-16 00:44:24
Logged In: YES 
user_id=32170

I have to say I don't know what the semantics of broken 
links should be in Tcl.  The current behaviour (after this 
patch is applied) is ok, but we probably should examine 
Tcl's filesystem in general and see where it might be 
tripped up by files disappearing on it, and then take 
appropriate, consistent action everywhere.

I'll put this patch into the core and mark this bug closed 
when I apply some other small filesystem changes which have 
cropped up.
hobbsplain2001-08-16 00:57:50
Logged In: YES 
user_id=72656

I don't think Tcl should ever panic on inconsistencies in 
the file system like this.  Return an error maybe, but not 
panic - that bombs out of everything.  This is a language, 
and it should be fault tolerant to the underlying system as 
much as possible.  Panics should be reserved for internal 
inconsistencies and Really Bad problems like no memory left.
vincentdarleyplain2001-08-16 15:57:39
Logged In: YES 
user_id=32170

Ok, I guess I agree with Jeff.  So the choices are:

(i) simply ignore the disappearance
(ii) warn the user by signalling an error (but this will of 
course abort the entire 'glob' in progress)

I guess I would vote for (i) in this particular case -- the 
user wants a list of files, but then one file has 
disappeared (or had some other OS problem) half way through 
so, it shouldn't be returned.  This behaviour kind of 
assumes that if we tried the 'readdir' a second time, it 
wouldn't return this particular file.
dkfplain2001-08-16 16:57:44
Logged In: YES 
user_id=79902

The key (I think) is that with [glob -type r *] the user is
asking for all files that can be opened by [open ... r]
without causing an error. Since that is not the case with a
broken link, it should not be returned. This assumption is
also true for -type x, but not necessarily for -type w (it
depends on whether creation is permitted in that directory)
but it wouldn't be harmful to exclude those too (it depends
on the interpretation of 'writable', but arguably a file is
not previously writable if you have to create it as part of
opening it for writing. Which is lucky since it makes the
implementation simpler. :^)
vincentdarley Closed ticket [417111ffff]. [History diff]2001-08-24 01:25:50
vincentdarleyplain2001-08-24 01:25:51
Logged In: YES 
user_id=32170

Fixed in cvs head
Log in (anonymous is fine) to add a comment.

Attachments: