From: SourceForge.net <no...@so...> - 2008-12-09 22:55:15
|
Bugs item #2407783, was opened at 2008-12-08 14:44 Message generated for change (Comment added) made by andreas_kupries You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=110894&aid=2407783&group_id=10894 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: 25. Channel System Group: current: 8.5.5 Status: Open Resolution: None Priority: 9 Private: No Submitted By: Schelte Bron (sbron) Assigned to: Andreas Kupries (andreas_kupries) Summary: Seek causes IO channel to be shared between all interps Initial Comment: I noticed that 'seek 0' on a file handle makes the handle accessible in all interps. I can't find any evidence in the docs that this is the intended behavior. Example: The following script will dump 2 x four bytes from /dev/random: interp create foo interp create bar set f [open /dev/random rb] interp eval foo { proc bytes {fh} { binary scan [read $fh 4] H* hex puts $hex close $fh } } interp eval bar { proc bytes {fh} { binary scan [read $fh 4] H* hex puts $hex close $fh } } seek $f 0 interp eval foo [list bytes $f] interp eval bar [list bytes $f] close $f Without the seek command it reports an error as expected: can not find channel named "file5" while executing "read $fh 4" (procedure "bytes" line 2) invoked from within "bytes file5" invoked from within "interp eval foo [list byte $f]" SuSE linux 11.0 Kernel 2.6.25.18-0.2-pae Tcl 8.5.5 ---------------------------------------------------------------------- Comment By: Andreas Kupries (andreas_kupries) Date: 2008-12-09 14:55 Message: Note 1: There is no Tcl_GetChannelFromObj(). Only a TclGetChannelFromObj(). I.e. internal, not public. Note 2: Trying to trace where the fix is in all the unrelated changes is ... not fun. There do not seem to be any changes to fix it. Tracing the TclGetChannelFromObj a bit it seems that in 8.6 something invalidates the intrep after the seek, before the 'puts' in interp foo is reached. So far no idea what. ---------------------------------------------------------------------- Comment By: Jeffrey Hobbs (hobbs) Date: 2008-12-09 14:54 Message: Donal's changes do not look like they intentionally changed any behavior. I'm skeptical that TclGetChannelFromObj is the source of the issue as it layers over Tcl_GetChannel, which maintains a table in the assocData of a single interp, and uses Tcl_Objs, which should not be shared. Am I missing something? ---------------------------------------------------------------------- Comment By: Andreas Kupries (andreas_kupries) Date: 2008-12-09 12:47 Message: Ok, coming to this I see the problem in 8.5, but not 8.6/Head. As I also saw a commit by dkf to tclIO.c I am assuming right now that the 'Refactoring tclIO.c' commit was (intended as) a fix for this. Meaning that I 'just' have to back port it. Is that correct, Donal ? ---------------------------------------------------------------------- Comment By: Donal K. Fellows (dkf) Date: 2008-12-09 03:47 Message: Diagnosis: leakage of file handle through Tcl_Obj internal rep. Problem is not [seek] itself, but rather Tcl_GetChannelFromObj. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=110894&aid=2407783&group_id=10894 |