![]() |
|
Problems? Is your data what you think it is? | |
PerlMonks |
Re: Re: Problem with filetest -x _ on Win2k AS Perl build 626by Rudif (Hermit) |
on Jul 01, 2001 at 21:45 UTC ( #93038=note: print w/replies, xml ) | Need Help?? |
>> Question to experienced monks: Where should I report the bug? ActiveState, or perl 5 porters? Rudif mumbling to himself ...
OK, I submitted a bug report to perlbug@perl.com, where it received ID 20010627.004. To investigate the problem further, I built the Perl locally (I had to tweak the makefile to get the symbols) and stepped in with a debugger (windbg). My conclusion: Microsoft implementation of C function _fstat() fails to set the 'Executable' bit correctly for an executable file, while their function _stat() does it correctly. The Perl implemetation of stat() calls _stat(), while the implementation of -T _ calls the rogue _fstat(). Below is my followup report to perl5porters. I hope I won't get flamed for posting C code along with perl code. Re ID 20010627.004 : I have a diagnostic I investigated some more the bug 20010627.004 and I have a diagnostic. 1. Summary I found that the failure of Perl filetest operator -x _ on Win2k to report an executable file as executable after a -T _ is due to discrepancy in st_mode values returned by Microsoft functions _stat() and _fstat(). Specifically, I found that _stat() sets the 3 Execute bits (mask 0111 octal) to 1 when it sees an executable file, while _fstat() sets these bits to 0 when looking at the same file. The C program below demonstrates. 2. Simplified test case Here is my simplified perl script that demonstrates the problem, in Active Perl build 626 as well as in my local build of Perl from sources currently (Jun 2001) distributed by ActiveState: It demonstrates that doing -T _ after stat() and before -x _ produces erroneous -x result. 3. Results of my investigation I looked into the implementation of Perl stat() and -T _. In fact, I ran the debugger windbg on my local build while running above test script. I found this: which explains the misbehavior that I am complaining about. I wrote a C test program that demonstrates the misbehavior (IMO) of Win32 fstat():
I included wording from MSDN doc pages on _stat() and _fstat(). The _stat() doc says that "user execute bits are set according to the filename extension.", while the _fstat() doc does NOT mention the "user execute bits". My observation is that _stat() does what the doc says, while _fstat() silently sets the "user execute bits" to 0. OUCH. I have found that above code compiles and produces that same results when I replace The later forms are documented in MSDN, while the former are not AFAICS. I am not clear on how does this relate (or not) to the ANSI C standard - IANAL. HTH Rudi Farkas rudif@bluemail.ch
In Section
Seekers of Perl Wisdom
|
|