New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
filetests sometimes do not set _ #9069
Comments
From Mark@Overmeer.netCreated by mark@overmeer.netOn the Perl5.10.0 of today (patch 32115), I see filetest errors which Somewhere in a large program, I do something like this: sub ... { And the result is "directory"!! with -o e z s f d u g k b c l T B M A C, it is reported as file. I have tried, but was not successful in reproducing the error in a Greetings, MarkOv Perl Info
|
From Mark@Overmeer.net* Mark Overmeer (perlbug-followup@perl.org) [071016 14:04]:
Hum... the error report was even more right than I expected it to be... The following script reports 'directory' twice: #!/usr/local/bin/perl5.10.0 -d '/etc'; Apparently, -r/-w/-x/-R/-W/-X implemented in filetest to not Mark Overmeer MSc MARKOV Solutions |
From @rgsOn 17/10/2007, Mark Overmeer <mark@overmeer.net> wrote:
Looking at the code, I think this bug was already present in 5.8.x. What does |
The RT System itself - Status changed from 'new' to 'open' |
From Mark@Overmeer.net* Rafael Garcia-Suarez (rgarciasuarez@gmail.com) [071017 08:49]:
markov@earth:&perl> perl5.10.0 -V:.*access.* markov@earth:&perl> perl5.8.7 -V:.*access.* The code which now fails was ran by cpan-testers on many many According to the cpantesters results By the way: quite some 5.9.5 tests reported successes, but actually Mark Overmeer MSc MARKOV Solutions |
From @andk
> The code which now fails was ran by cpan-testers on many many > According to the cpantesters results Binary search reveals the test fails since 25986 Change 25986 by nicholas@nicholas-saigo on 2005/11/04 13:02:42 ftrwrite, ftrexec, fteread, ftewrite and fteexec can all be merged -- |
From @nwc10On Thu, Oct 18, 2007 at 05:29:36AM +0200, Andreas J. Koenig wrote:
Mmm, I'm not sure about this. The script starts failing for me on 5.8.1 $ cat 46463 -d '/etc'; It's also failing on 5.6.2: $ /usr/local/perl/5.6.2/bin/perl ~/p4perl/perl/46463 Nicholas Clark |
From @andk
> On Thu, Oct 18, 2007 at 05:29:36AM +0200, Andreas J. Koenig wrote:
> Mmm, I'm not sure about this. The script starts failing for me on 5.8.1 > $ cat 46463 > -d '/etc'; Ahh, this is a different bug then. Mark told us that he could not ----Program---- ----Output of .../plC1Mru/perl-5.8.0@25985/bin/perl---- ----EOF ($?='0')---- ----EOF ($?='0')---- The N/A comes from the fact that the test suite failed. Whereas your program says "directory" on both 2598[56]. A binary search for your program leads us to the interval between -- |
From Mark@Overmeer.net* Andreas J. Koenig (andreas.koenig.7os6VVqR@franz.ak.mind.de) [071018 19:46]:
You may be very right. This script does shows the same problem and Remove the 'use filetest', or use f.i. -s i.s.o -w does solve the In the program the situation is far more complex: the '-d' is run I have tried and tried, but no luck on a small example which does unpack Mail::Box-*gz tests 3 and 4 fail. They call Mail::Box::Mbox::listSubFolders(). My hopes are that a fix for above bug will fix the second. MarkOv Mark Overmeer MSc MARKOV Solutions |
From @andk
> A binary search for your program leads us to the interval between ---Program---- -d '/etc'; ----Output of .../pwzF3Lg/perl-5.8.0@19391/bin/perl---- ----EOF ($?='0')---- ----EOF ($?='0')---- Change 19392 by jhi@kosh on 2003/05/03 05:33:04 Salvage 'use filetest "access"' from compiletime to runtime. -- |
From @nwc10On Wed, Oct 17, 2007 at 10:22:58AM +0200, Mark Overmeer wrote:
On Fri, Oct 19, 2007 at 02:20:26AM +0200, Andreas J. Koenig wrote:
It seems that Jarkko actually fixed a bug here - I'd infer that access() wasn't I don't believe that the current behaviour is a behavioural bug. It is documented that _ is set to the last stat. Hence one does not need to call stat(), so perl does not. *That* So I think that the current behaviour is preferable. If we changed it so that I'm curious - on a modern Unix system with decent OS caching, how much does Nicholas Clark |
From Mark@Overmeer.net* Nicholas Clark (nick@ccl4.org) [071021 20:53]:
Oh, that's a good reason for that patch, and does explain things.
Well, perldoc -f stat says: if "stat" is passed the special filehandle consisting of an I do read "filetest" here... (perl5.10.0)
On many places, Perl prefers qualilty over performance. I would even That file test behavioral change when 'use filetest' is given somewhere On the other hand, the whole use of -w / -r /-x should be avoided in
Probably only an extra context switch. (Do you known how many a simple Mark Overmeer MSc MARKOV Solutions |
From Mark@Overmeer.netGuys, What will happen with the reported bug? I don't like the silence IMO, we should decide between: (1) change the docs, reflecting the special behavior of (2) produce an error when _ is used when filetest is enabled. (3) change the internal implementation of -r/-w/-x to use IMO, (3) [filetest is always used] is strongly preferred: if you test But this probably shouldn't go into 5.10... At least the first
* Mark Overmeer (mark@overmeer.net) [071022 00:47]:
MarkOv Mark Overmeer MSc MARKOV Solutions |
From @rgsOn 02/11/2007, Mark Overmeer <mark@overmeer.net> wrote:
That's the best we can do for 5.10.0 I think. A good place to patch |
From Mark@Overmeer.net* Rafael Garcia-Suarez (rgarciasuarez@gmail.com) [071102 15:27]:
Just at the last moment, two proposed updates to perlfunc/-X and Mark Overmeer MSc MARKOV Solutions |
From Mark@Overmeer.netInline Patch--- pod/perlfunc.pod.old 2007-11-30 11:19:32.000000000 +0100
+++ pod/perlfunc.pod 2007-11-30 11:33:46.000000000 +0100
@@ -341,13 +341,16 @@
#...
}
-The interpretation of the file permission operators C<-r>, C<-R>,
-C<-w>, C<-W>, C<-x>, and C<-X> is by default based solely on the mode
-of the file and the uids and gids of the user. There may be other
-reasons you can't actually read, write, or execute the file. Such
-reasons may be for example network filesystem access controls, ACLs
-(access control lists), read-only filesystems, and unrecognized
-executable formats.
+The interpretation of the file permission operators C<-r>, C<-R>, C<-w>,
+C<-W>, C<-x>, and C<-X> is by default based solely on the mode of the
+file and the uids and gids of the user. There may be other reasons you
+can't actually read, write, or execute the file: for example network
+filesystem access controls, ACLs (access control lists), read-only
+filesystems, and unrecognized executable formats. The use of these six
+specific operators is usually a mistake in the first place, because it
+may be open to race conditions. See the filetest pragma manual L<filetest>
+for a better approach and more details, but be warned that the filetest
+pragma may cause C<_> not to be set!
Also note that, for the superuser on the local filesystems, the C<-r>,
C<-R>, C<-w>, and C<-W> tests always return 1, and C<-x> and C<-X> return 1
@@ -355,16 +358,6 @@
may thus need to do a stat() to determine the actual mode of the file,
or temporarily set their effective uid to something else.
-If you are using ACLs, there is a pragma called C<filetest> that may
-produce more accurate results than the bare stat() mode bits.
-When under the C<use filetest 'access'> the above-mentioned filetests
-will test whether the permission can (not) be granted using the
-access() family of system calls. Also note that the C<-x> and C<-X> may
-under this pragma return true even if there are no execute permission
-bits set (nor any extra execute permission ACLs). This strangeness is
-due to the underlying system calls' definitions. Read the
-documentation for the C<filetest> pragma for more information.
-
Note that C<-s/a/b/> does not do a negated substitution. Saying
C<-exp($foo)> still works as expected, however--only single letters
following a minus are interpreted as file tests. |
From @jhihttp://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2007-11/msg01085.html In principle I approve clarifications but it seems to me that you are |
From Mark@Overmeer.net* Jarkko Hietaniemi (jhi@iki.fi) [071130 12:55]:
Please be specific Mark Overmeer MSc MARKOV Solutions |
From @jhiWhat exactly are you trying to add / change? Something about the On Nov 30, 2007 8:11 AM, Mark Overmeer <mark@overmeer.net> wrote:
-- |
From Mark@Overmeer.net
* Jarkko Hietaniemi (jhi@iki.fi) [071130 14:06]:
The changed text should reflect the debates on the porters lists, which in short -r $filename no filetest 'access' # default use filetest 'access' Under the filetest pragma, -r/-w/-x do not set '_'. There was no IMO, filetest 'access' should be default, and we should try to trick The patches I provide include two major changes. Changes to the text are (of course) possible. At least, this suggestion MarkOv Mark Overmeer MSc MARKOV Solutions |
From @nwc10On Fri, Nov 30, 2007 at 05:05:31PM +0100, Mark Overmeer wrote:
Changing code always has the possibility of adding a bug. This should be
My opinion is that forcing everyone to take a speed hit to protect against I assume that it would be possible for the implementation of the filetest It, presumably, would also be possible to have the filetest pragma be able Nicholas Clark |
From Mark@Overmeer.net* Nicholas Clark (nick@ccl4.org) [071203 14:52]:
It is documented in with the access pragma.
Depends on the hit. Doing a stat() is mainly a wait-for-disk. A stat() A speed it of a few percent (extra context switch maybe) is not bad.
Of course, possible. Not so easy to get right.
I am always proud on Perl, that it does not bother people with string MarkOv Mark Overmeer MSc MARKOV Solutions |
From @hvdsNicholas Clark <nick@ccl4.org> wrote: It need not be a stat()-sized speed hit if after an access we set a flag That reduces the universal hit to checking a flag on access of C<_>, and Hugo |
From Mark@Overmeer.net* hv@crypt.org (hv@crypt.org) [071204 13:27]:
With all these solutions, you introduce a danger -r $filename; The more I think about it, the more convinced I am that -r/-w/-x in any Maybe, we should move into the direction where we add the provide The -r/-w/-x should than be documented as Mark Overmeer MSc MARKOV Solutions |
From @rgsOn 05/12/2007, Mark Overmeer wrote:
One of the goals (in my mind) of introducing stacked filetest operators
Oh, no, not File::Spec for that !
That wouldn't solve the race condition problem. I think the only sure |
From Mark@Overmeer.net* Rafael Garcia-Suarez (rgarciasuarez@gmail.com) [071205 10:33]:
Well, I think that the module is outdated as well... but it looks
This is very true... although there are situations that the readability if(open F, '<', $fn) but it is nicer to be able to do if(is_readable $fn) For instance, the auto-completion of bash only suggests files which can MarkOv Mark Overmeer MSc MARKOV Solutions |
From @rgsOn 30/11/2007, Mark Overmeer <mark@overmeer.net> wrote:
Thanks, I've applied modified/augmented/rephrased versions of those to |
@smpeters - Status changed from 'open' to 'resolved' |
From solutions@overmeer.net* Steve Peters via RT (perlbug-followup@perl.org) [081107 20:39]:
Well, if you declare that "documenting a problem" is equivalent to It could be solved by calling stat() also when in "use filetest 'access';" Mark Overmeer MSc MARKOV Solutions |
Migrated from rt.perl.org#46463 (status was 'resolved')
Searchable as RT46463$
The text was updated successfully, but these errors were encountered: