Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2019-10-28
19:26 • Closed ticket [bcd1004104]: A change to the system encoding, a stale cached file... artifact: 5f828e2f8a user: pooryorick
16:41 • Pending ticket [bcd1004104]. artifact: a97e4a452f user: jan.nijtmans
16:40
Put back tests/fileSystemEncoding.test, but now don't run it on Windows, since the NTFS doesn't the ... check-in: bf8356de35 user: jan.nijtmans tags: core-8-6-branch
16:25 • Ticket [bcd1004104] A change to the system encoding, a stale cached file FsPath ... artifact: c7f42ad369 user: jan.nijtmans
16:21 • Ticket [bcd1004104]: 3 changes artifact: 5e0cc0d2fb user: jan.nijtmans
16:11 • Ticket [bcd1004104]: 3 changes artifact: 8c992d4309 user: pooryorick
16:08 • Ticket [bcd1004104]: 3 changes artifact: 5dc84be961 user: pooryorick
08:58 • Ticket [bcd1004104]: 4 changes artifact: b735aabba7 user: jan.nijtmans
08:37
Close fork, and temporary remove tests/fileSystemEncoding.test, since apparently bug [bcd1004104] is... check-in: 2b5fba9174 user: jan.nijtmans tags: core-8-6-branch
08:25 • Ticket [bcd1004104] A change to the system encoding, a stale cached file FsPath ... artifact: 2acd81af3a user: jan.nijtmans
08:25 • Ticket [bcd1004104]: 3 changes artifact: 13c5511d64 user: jan.nijtmans
2019-10-26
17:52
Test for [bcd100410465] and add ::tcltests::tempdir. check-in: c353b10c81 user: pooryorick tags: core-8-branch
17:47
More simple fix for [bcd100410465], stale cached file FsPath object. check-in: 0edc8ab6e3 user: pooryorick tags: core-8-branch
17:36
More simple fix for [bcd100410465], stale cached file FsPath object. check-in: 7bc367ea81 user: pooryorick tags: bug-bcd1004104
15:43
Test for issue [bcd1004104651], and new routine, ::tcltests::tempdir. check-in: edb36812e0 user: pooryorick tags: core-8-6-branch
15:42 • Ticket [bcd1004104] A change to the system encoding, a stale cached file FsPath ... artifact: f94e3082a9 user: pooryorick
14:14
Fix for [bcd100410465], stale cached file FsPath object check-in: 440efbd556 user: pooryorick tags: core-8-6-branch
2019-10-25
00:43 • Ticket [bcd1004104] A change to the system encoding, a stale cached file FsPath ... artifact: ca1d22b259 user: bll
2019-10-24
23:05 • Ticket [bcd1004104]: 3 changes artifact: 7e11d2e608 user: bll
23:01 • Ticket [bcd1004104]: 3 changes artifact: 49eca8a361 user: bll
21:19 • Ticket [bcd1004104]: 3 changes artifact: b1d5c06111 user: pooryorick
21:04 • Ticket [bcd1004104]: 3 changes artifact: da7e31e160 user: jan.nijtmans
20:33 • Ticket [bcd1004104]: 3 changes artifact: 686740113b user: pooryorick
08:29 • Ticket [bcd1004104]: 3 changes artifact: 523cc39fb0 user: jan.nijtmans
08:16
Put work on ticket [bcd1004104] in a separate branch. Currently test-case encoding-2.2 fails. check-in: adb6794b6f user: jan.nijtmans tags: bug-bcd1004104
2019-10-22
22:11 • Ticket [bcd1004104] A change to the system encoding, a stale cached file FsPath ... artifact: e82c4981ce user: jan.nijtmans
19:21
Fix for [bcd1004104] check-in: 0f2870649c user: pooryorick tags: core-8-branch
18:10 • Ticket [bcd1004104] A change to the system encoding, a stale cached file FsPath ... artifact: a145253983 user: pooryorick
14:27 • New ticket [bcd1004104]. artifact: de6df813f6 user: pooryorick

A change to the system encoding, a stale cached file FsPath object, and an incorrect result

Closed / Fixedbcd1004104651998d1ae99aa6869e249c0ed0019Created 7 years agoUpdated 7 years ago
Descriptionwiki2019-10-22 14:27:51
The ext file system has no concept of "encoding": It names a file exactly the sequence of octets it is handed. In the following script, iso8859-1 is used to create a file, and then that same sequence of octets is obtained using glob. Then an FsPath object created under a different system encoding is created and cached. Later on that FsPath object is used under the original system encoding when it shouldn't be.

set name  登鸛鵲樓

encoding system iso8859-1

# create an iso8859-1-compatible sequence of octets to name the file by.
# They happen to be a string encoded in utf-8, but that's irrelevant.
set utf8 [encoding convertto utf-8 $name]

set chan [open $utf8 w]
puts $chan hello
close $chan

#
lassign [glob -directory [pwd] *$utf8*] fname



encoding system utf-8

# The sequence of octets is now itself converted to utf-8. Such a file does not
# exist, and a FsPath object has been cached.  So far so good.
puts [list utf-8 [file exists $fname]] ;#-> 0
encoding system iso8859-1

# Here the answer here should be 1, but the FsPath object created under a
# previous system encoding is used when it shouldn't be.
puts [list iso8859-1 [file exists $fname]]  ;# -> 0

# Discard the cached FsPath object, causing a new FsPath to be created using
# the (currently correct) system encoding.
puts [list iso8859-1 {string range} [file exists [string range $fname 0 end]]]  ;# -> 1
Referenced by4
  • bf8356de35Put back tests/fileSystemEncoding.test, but now don't run it on Windows, since the NTFS doesn't the system encoding, therefore doesn't expose bug [bcd1004104]. check-in2019-10-28 16:40:08
  • 2b5fba9174Close fork, and temporary remove tests/fileSystemEncoding.test, since apparently bug [bcd1004104] is not fixed yet on Windows. check-in2019-10-28 08:37:30
  • adb6794b6fPut work on ticket [bcd1004104] in a separate branch. Currently test-case encoding-2.2 fails. check-in2019-10-24 08:16:55
  • 0f2870649cFix for [bcd1004104] check-in2019-10-22 19:21:48
pooryorick Ticket [bcd1004104]: 3 changes [History diff]2019-10-22 18:10:35
jan.nijtmanswiki2019-10-22 22:11:24

Starting with [0f2870649c804dd8]:

encoding.test

==== encoding-2.2 Tcl_FreeEncoding: refcount != 0 FAILED ==== Contents of test case:

encoding system shiftjis ;# incr ref count encoding dirs [list [pwd]] set x [encoding convertto shiftjis \u4e4e] ;# old one found encoding system iso8859-1 llength shiftjis ;# Shimmer away any cache of Tcl_Encoding lappend x [catch {encoding convertto shiftjis \u4e4e} msg] $msg

---- Result was: ŒÁ 0 ŒÁ ---- Result should have been (exact matching): ŒÁ 1 {unknown encoding "shiftjis"} ==== encoding-2.2 FAILED

jan.nijtmanswiki2019-10-24 08:29:22

Since Travis already fails for 2 days, I put the work on this ticket in a separate [bug-bcd1004104] branch. Please have a look: Something still wrong with the code, or should the test-case be revised?

pooryorickwiki2019-10-24 20:33:51

The failue of encoding-2.2 was fixed by adding a corresponding Tcl_FreeEncoding for the newly-added Tcl_GetEncoding.

There's more work to be done on this issue though. There might be undesired interactions between FsPath.nativePathPtr and FsPath.filesystemEpoch. These are older issues, not something introduced by the current changes.

jan.nijtmansplain2019-10-24 21:04:02
Hm ...  Added the Tcl_FreeEncoding() now, it doesn't seem to work ...

Anyway, I'll leave the branch to you, in case you want to work on it further. Please, next time, don't merge it to core-8-branch as long as you are not reasonable confident that all test-cases work.

Thanks!
pooryorickwiki2019-10-24 21:19:03

The initially-provided example behaves as described in core-8-6-branch, but in core-8-branch only behaves as described prior to commit [165586b224f85f10], " TIP #430 implementation", 2018-09-12. This is because even when built with --disable-zipfs, in core-8-branch there are calls to ZipFSPathInFilesystemProc from Tcl_FSGetFileSystemForPath, and ZipFSPathInFilesystemProc uses Tcl_GetString(pathPtr) instead of working with the fsPathType internal representation.

bllplain2019-10-24 23:01:10
Unable to reproduce with tcl 8.6.9 on Linux.
bllplain2019-10-24 23:05:35
Unable to reproduce:
  8.6.9 on MX Linux 19
  8.6.5 on Ubuntu 16.04
bllplain2019-10-25 00:43:34
Ok, reproduced.
pooryorickwiki2019-10-26 15:42:06

Fixed in [440efbd556ce7041] for core-8-6-branch. In contrast with the proposed fix for the core-8-branch, this is a one-line fix. It should probably also be applied to core-8-branch, and additional work done there to refine the record keeping when system encoding changes.

jan.nijtmanswiki2019-10-28 08:25:03

On UNIX, it appears to work, but all travis Windows builds are failing:

==== filesystemEncoding-1.0 issue bcd100410465 FAILED
==== Contents of test case:
	set dir [tcltests::tempdir]
	set saved [encoding system]
	encoding system iso8859-1
	set fname1a $dir/$fname1
	set utf8name [encoding convertto utf-8 $fname1a]
	makeFile {} $utf8name
	set globbed [lindex [glob -directory $dir *] 0]
	encoding system utf-8
	lappend res [file exists $globbed]
	encoding system iso8859-1 
	lappend res [file exists $globbed]
	return $res

---- Result was: 1 1 ---- Result should have been (exact matching): 0 1 ==== filesystemEncoding-1.0 FAILED

This way Donald Porter cannot make his RC, so please have a look at this!

jan.nijtmans Ticket [bcd1004104]: 3 changes [History diff]2019-10-28 08:25:16
jan.nijtmansplain2019-10-28 08:58:50
I just removed the filesystemEncoding test-case now, knowing that this bug is still not solved for Windows. That means, it's not critical any more now.
pooryorickwiki2019-10-28 16:08:06

Maybe I'm wrong, but because NTFS has a native encoding whereas common *NIX filsystems do not, this test can not be adapted for NTFS. Therefore it could be constrained to *NIX systems rather than removed.

pooryorickwiki2019-10-28 16:11:46

The bug can not be reproduced on NTFS filesystems in the first place. That's why with an NTFS filesystem the first result of filesystemEncoding-1.0 is 1 rather than 0.

jan.nijtmansplain2019-10-28 16:21:10
Or ... just change the expected test result for UNIX ...
jan.nijtmanswiki2019-10-28 16:25:29

> Or ... just change the expected test result for UNIX ...

Of course, I meant Windows here ....

jan.nijtmansplain2019-10-28 16:41:56
Well, I put back the test, so is this one fixed now?
pooryorick Closed ticket [bcd1004104]. [History diff]2019-10-28 19:26:14
Log in (anonymous is fine) to add a comment.