Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2018-07-16
14:30 • New ticket [61fa4879ed] RFE: use system temp-folder as default temporary directo... artifact: 0bae4efd4f user: sebres
14:01 • Closed ticket [525ccacaef]: win: strange discrepancy regarding Tcl_FSStat (all f... artifact: b8e69a5fae user: sebres
13:59
win: fixed test-cases (see [525ccacaef]) running under windows outside of temp-folder check-in: d61a95dfb6 user: sebres tags: core-8-6-branch
13:58 • Ticket [525ccacaef] win: strange discrepancy regarding Tcl_FSStat (all file sub-... artifact: 6c10029750 user: sebres
13:13 • Ticket [525ccacaef]: 3 changes artifact: 60f8f8ca4c user: apnadkarni
10:33 • Ticket [525ccacaef]: 3 changes artifact: 2627bf86e2 user: sebres
2018-07-14
03:35 • Ticket [525ccacaef]: 3 changes artifact: 60c3117667 user: apnadkarni
03:32 • Ticket [525ccacaef]: 3 changes artifact: ebc4272e14 user: apnadkarni
2018-07-13
22:27 • Ticket [525ccacaef]: 3 changes artifact: f8ffee3bd3 user: bll
19:08 • New ticket [525ccacaef]. artifact: 6f467290dd user: sebres

win: strange discrepancy regarding Tcl_FSStat (all file sub-commands using GetStatBuf) corresponding path by "built-in Windows names with dir path and extension"

Closed / Fixed525ccacaef84745d0a5ed72060f208626291077cCreated 8 years agoUpdated 8 years ago
Descriptionwiki2018-07-13 19:08:21
I found very weird discrepancy regarding Tcl_FSStat using 8.6 under Windows for file sub-commands (that use GetStatBuf), depending from used path by "built-in Windows names with dir path and extension".

The explanation, what happens, could be provided from this script:

proc test_fs_nef {{path {}} {fn this-file-does-not-exists.txt}} {
  puts "[set fn [file join $path $fn]] ..."
  puts -nonewline [format [string repeat "  %-8s: \[%d\] %s\n" 5] \
    atime [catch {file atime $fn} r] $r \
    mtime [catch {file mtime $fn} r] $r \
    size  [catch {file size $fn} r] $r \
    stat  [catch {file stat $fn stat} r] "$r [array get stat]" \
    type  [catch {file type $fn} r] $r \
  ]
}

puts [test_fs_nef [info library]] puts [test_fs_nef [info library] CON.txt]

puts [test_fs_nef $::env(TEMP)] puts [test_fs_nef $::env(TEMP) CON.txt]; ## here something goes broken!!!

results in:
D:/Projects/tcl8.6-upstream/library/this-file-does-not-exists.txt ...
  atime   : [1] could not read "D:/Projects/tcl8.6-upstream/library/this-file-does-not-exists.txt": no such file or directory
  mtime   : [1] could not read "D:/Projects/tcl8.6-upstream/library/this-file-does-not-exists.txt": no such file or directory
  size    : [1] could not read "D:/Projects/tcl8.6-upstream/library/this-file-does-not-exists.txt": no such file or directory
  stat    : [1] could not read "D:/Projects/tcl8.6-upstream/library/this-file-does-not-exists.txt": no such file or directory
  type    : [1] could not read "D:/Projects/tcl8.6-upstream/library/this-file-does-not-exists.txt": no such file or directory

D:/Projects/tcl8.6-upstream/library/CON.txt ... atime : [1] could not read "D:/Projects/tcl8.6-upstream/library/CON.txt": no such file or directory mtime : [1] could not read "D:/Projects/tcl8.6-upstream/library/CON.txt": no such file or directory size : [1] could not read "D:/Projects/tcl8.6-upstream/library/CON.txt": no such file or directory stat : [1] could not read "D:/Projects/tcl8.6-upstream/library/CON.txt": no such file or directory type : [1] could not read "D:/Projects/tcl8.6-upstream/library/CON.txt": no such file or directory

C:/Temp/this-file-does-not-exists.txt ... atime : [1] could not read "C:/Temp/this-file-does-not-exists.txt": no such file or directory mtime : [1] could not read "C:/Temp/this-file-does-not-exists.txt": no such file or directory size : [1] could not read "C:/Temp/this-file-does-not-exists.txt": no such file or directory stat : [1] could not read "C:/Temp/this-file-does-not-exists.txt": no such file or directory type : [1] could not read "C:/Temp/this-file-does-not-exists.txt": no such file or directory C:/Temp/CON.txt ... atime : [1] could not get access time for file "C:/Temp/CON.txt" mtime : [1] could not get modification time for file "C:/Temp/CON.txt" size : [0] 0 stat : [0] mtime 0 atime 0 gid 0 nlink 0 mode 8630 type characterSpecial ctime 0 uid 0 ino 0 size 0 dev -1 type : [0] characterSpecial

The guess that something may be wrong on Windows self (e. g. other return code from WinAPI) has not been confirmed: the same script executed for 8.5th returns the expected results in the last case (exactly as for all 3 first cases). It's not the path and file-name alone, because this weird behavior happens only by the combination temp-path together with "CON.txt".

This reflects why the several cmdAH-test-cases fail if used without -tmpdir and successful with -tmpdir parameter.

.\tclsh86 ..\..\tests\all.tcl -file "cmdAH.*"
  cmdAH-20.7.1 FAILED
  cmdAH-24.14.1 FAILED
  cmdAH-27.4.1 FAILED
  cmdAH-28.13.1 FAILED
  cmdAH-29.6.1 FAILED
Total   320     Passed  140     Skipped 175     Failed  5

.\tclsh86 ..\..\tests\all.tcl -file "cmdAH.*" -tmpdir %TEMP% Total 320 Passed 145 Skipped 175 Failed 0

Referenced by2
  • 0bae4efd4fNew ticket [61fa4879ed] RFE: use system temp-folder as default temporary directory in test-suite. ticket2018-07-16 14:30:32
  • d61a95dfb6win: fixed test-cases (see [525ccacaef]) running under windows outside of temp-folder check-in2018-07-16 13:59:29
bllplain2018-07-13 22:27:28
Maybe some special case processing for the CON: device
that has gone wrong???
apnadkarniplain2018-07-14 03:32:54
From the documentation - " If the file does not exist or its access time cannot be queried or set then an error is generated."

For the built-in devices like CON on Windows, access and modification times are not maintained. I had changed the code to raise an error accordingly as logged in some old ticket.

However, I am fairly certain all tests passed at the time I made the change (it was a while ago) so either these are new tests or something else has changed.

/Ashok
apnadkarniplain2018-07-14 03:35:49
https://core.tcl.tk/tcl/tktview?name=ae61a67192 is the specific ticket. Change was made in July 2016.
sebreswiki2018-07-16 10:33:05

@Ashok, you've certainly overseen, that all this the test-cases you've made, fail only in if no tmpdir specified (see again the ticket description about the combination where it has different behavior). Neither the test-cases are changed, nor something else (I tested your commit [5e0bded748], it fails likewise if no temp-dir specified.)

Which windows-version do you used?

apnadkarniplain2018-07-16 13:13:40
It was two years ago so most likely it would have been either XP or Windows 8 I suspect. I don't think I'd moved to Windows 10 by that time.

Also, rethinking the issue I'm wondering whether rather than being pedantic, from a practical point of view it would have been better to have returned 0 as the time instead of raising an error. I still don't feel good about "lying" about the timestamp like that though. Also, I don't think that it is relevant to this specific ticket since you are addressing why the behaviour is *different* in the two cases as opposed to what the specific behaviour is.

/Ashok
sebresplain2018-07-16 13:58:11
Yep that was the reason.
But I found the difference - in case of con.txt in temp-folder the NativeStat does open it with CreateFile (but GetFileInformationByHandle fails) and GetFileType returns 2 (FILE_TYPE_CHAR), so ignored in 8.6 (but returns ENOENT in 8.5).

So we can ignore it (as weird Windows hack) and I'll repair the test-cases now.
sebreswiki2018-07-16 14:01:13

fixed in [d61a95dfb6], this close.

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