View Ticket
2010-10-16
21:29 Closed ticket [0990f53b1a]: PNG files in Metakit4 VFSes fail to be read correctly plus 2 other changes artifact: 950cd89836 user: rkeene
21:28
Added patch from P. Thoyts fixing async channel copies in mk4vfs. This closes bug [0990f53b1a]. check-in: ae7d9fc61b user: rkeene tags: trunk
21:17 Ticket [0990f53b1a] PNG files in Metakit4 VFSes fail to be read correctly status still Open with 1 other change artifact: 0cf55f14c8 user: rkeene
21:15 Ticket [0990f53b1a]: 1 change artifact: 02bfa82328 user: rkeene
21:14 Ticket [0990f53b1a]: 1 change artifact: 291f22cf85 user: rkeene
21:13 Ticket [0990f53b1a]: 1 change artifact: 8761fe6055 user: rkeene
21:12 Ticket [0990f53b1a]: 2 changes artifact: e49f89ab8d user: rkeene
2010-10-13
15:52 Ticket [0990f53b1a]: 1 change artifact: ed7db63c32 user: rkeene
15:45 Ticket [0990f53b1a]: 1 change artifact: 2fca045077 user: rkeene
15:42 Ticket [0990f53b1a]: 1 change artifact: 3f6c6ead56 user: rkeene
15:29 Ticket [0990f53b1a]: 4 changes artifact: 625c3d95ab user: rkeene
15:09 Add attachment cross.png to ticket [0990f53b1a] artifact: 46090d3a50 user: rkeene
14:59 New ticket [0990f53b1a] PNG files in Metakit4 VFSes fail to be read correctly. artifact: 402055df96 user: rkeene

Ticket Hash: 0990f53b1a77cacafccaf440d277edeae0cab70a
Title: PNG files in Metakit4 VFSes fail to be read correctly
Status: Closed Type: Code Defect
Severity: Severe Priority: Immediate
Subsystem: Mk4tcl Resolution: Fixed
Last Modified: 2010-10-16 21:29:57
Version Found In: 0.5.2
Description:
Reported by JDC: http://groups.google.com/group/starkit/browse_frm/thread/5827418f4a2b80e7

PNG files read from an mk4vfs can fail to be read. Likely an issue in vfs::zstreamed in tclvfs.

It happens on non-KitCreator Tclkits too.


rkeene added on 2010-10-13 15:29:31:

  1. Create mk4vfs
    1. $ mkdir x.vfs
    2. $ cp cross.png x.vfs/
    3. $ ./tclkit-8.5.9-linux-i686 sdx.kit wrap x
    4. 1 updates applied
  2. Test reading "cross.png" from the mk4vfs
    1. % vfs::mk4::Mount x x
    2. mk4vfs1
    3. % cd x
    4. % glob *
    5. cross.png
    6. % set fd [open cross.png]
    7. mk7
    8. % fconfigure $fd -translation binary
    9. % set data [read $fd]; puts [string length $data]
    10. 655
    11. % binary scan $data H* data_hex
    12. 1
    13. % puts $data_hex
    14. 89504e470d0a1a0a0000000d49484452
    15. ...
    16. d9fef59bc28563bc6cfd0672bba4c7db
    17. edbe140000000049454e44ae426082

rkeene added on 2010-10-13 15:42:47:
It works in the trivial case posted previously, but fails with the following kit: http://code.google.com/p/wubwikit/downloads/detail?name=wub-20100922.kit

In the kit:

% set fd [open cross.png]
mk7
% fconfigure $fd -encoding binary
% set data [read $fd]; puts [string length $data]
654
% file stat cross.png x
% parray x
x(atime)   = 1285147347
x(blksize) = 135312827
x(blocks)  = 583863729869319636
x(ctime)   = 1285147347
x(dev)     = -143965300
x(gid)     = 0
x(ino)     = 0
x(mode)    = 33279
x(mtime)   = 1285147347
x(nlink)   = 1
x(size)    = 655
x(type)    = file
x(uid)     = 0

rkeene added on 2010-10-13 15:45:53:
Still not sure where this is failing.

% mk::loop x db.dirs!90.files { puts "$x, [mk::get $x name]" }
db.dirs!90.files!0, cross.png
db.dirs!90.files!1, tick.png
db.dirs!90.files!2, tclp.gif
% mk::view info db.dirs!90.files  
name size:I date:I contents:B
% mk::get db.dirs!90.files!0 size
655
% string length [mk::get db.dirs!90.files!0 contents]
655
% mk::get db.dirs!90.files!0 -size contents
655
%

rkeene added on 2010-10-13 15:52:42:
Oh, wait I did "-encoding binary" in my second test where it should have been "-translation binary".

Using "-translation binary" causes it to be read correctly.

% set fd [open cross.png r]
mk7
% fconfigure $fd -translation binary         
% set data [read $fd]; puts [string length $data]
655
% binary scan $data H* data_hex
1

rkeene added on 2010-10-16 21:12:41:
The issue only occurs when using [fcopy] and mk4vfs channels without direct mode.

Simple test:

vfs::mk4::Mount test.mk /TEST
set fd [open /TEST/cross.png]
fconfigure $fd -translation binary
set out [open /dev/null w]
set ::fcopy_complete 0
proc fcopy_complete {args} { set ::fcopy_complete 1 }
fcopy $fd $out -command fcopy_complete
after 3000
update
puts "FCOPY: $fcopy_complete"

rkeene added on 2010-10-16 21:14:10:
P. Thoyts came up with a patch for this: http://github.com/patthoyts/kitgen/commit/3ee246892b79bb83c8c96a2646124c6da94bbd3e


rkeene added on 2010-10-16 21:15:12:
Patch from P. Thoyts fixes the problem, but the test case segfaults on exit.

Backtrace follows:

(gdb) bt
#0  0x08075599 in Tcl_GetAssocData ()
#1  0x0804d67a in mkClose (instanceData=0x8170380, interp=0x0) at ../tcl/mk4tcl.cpp:326
#2  0x080b86de in TclFinalizeIOSubsystem ()
#3  0x0809d004 in Tcl_FinalizeThread ()
#4  0x0809d160 in Tcl_Finalize ()
#5  0x0809d518 in Tcl_Exit ()
#6  0x08080274 in Tcl_ExitObjCmd ()
#7  0x08077903 in TclEvalObjvInternal ()
#8  0x0807857d in Tcl_EvalEx ()
#9  0x080bf7d7 in Tcl_FSEvalFile ()
#10 0x080c2d52 in Tcl_Main ()
#11 0x0804c2aa in main (argc=135724192, argv=0x2004) at main.c:11
(gdb) 

rkeene added on 2010-10-16 21:29:57:
Fixed in [ae7d9fc61b].


Attachments: