| Ticket UUID: | 636161 | ||
| Title: | Tcl_FS* problems on windows&threads | ||
| Type: | Bug | Created on: | 2002-11-10 11:26:49 |
| Submitter: | zoro2 | Assigned to: | andreas_kupries |
| Subsystem: | 25. Channel System | Severity: | |
| Priority: | 2 | Last modified: | 2003-05-12 22:37:13 |
| Status: | Open | Closed by: | |
| Resolution: | None | Closed on: | |
| Version: | obsolete: 8.4.1 | ||
| Description: | ||||
This simple code (run inside a threaded tclkit with
Itcl liked static) breaks on Windows:
package require Thread
load {} Itcl
set id [thread::create]
thread::send $id {load {} Itcl}
It panics out in thread's Tcl_FSEvalFile:
#0 0x004149db in Tcl_Close ()
#1 0x00452e2a in Tcl_FSEvalFile ()
#2 0x0042edbe in Tcl_SourceObjCmd ()
#3 0x00405bc6 in TclEvalObjvInternal ()
#4 0x00405d6f in Tcl_EvalObjv ()
#5 0x004069a4 in Tcl_EvalObjEx ()
#6 0x0042cabb in Tcl_UplevelObjCmd ()
#7 0x00405bc6 in TclEvalObjvInternal ()
#8 0x0042375e in TclExecuteByteCode ()
#9 0x00422ad3 in TclCompEvalObj ()
#10 0x0042d0e1 in TclObjInterpProc ()
#11 0x00405bc6 in TclEvalObjvInternal ()
#12 0x0042375e in TclExecuteByteCode ()
#13 0x00422ad3 in TclCompEvalObj ()
#14 0x0042d0e1 in TclObjInterpProc ()
#15 0x00405bc6 in TclEvalObjvInternal ()
#16 0x00405ac3 in TclEvalObjvInternal ()
#17 0x00406533 in Tcl_EvalEx ()
#18 0x00452e70 in Tcl_FSEvalFile ()
#19 0x0042edbe in Tcl_SourceObjCmd ()
#20 0x00405bc6 in TclEvalObjvInternal ()
#21 0x00405d6f in Tcl_EvalObjv ()
#22 0x004069a4 in Tcl_EvalObjEx ()
#23 0x0042cabb in Tcl_UplevelObjCmd ()
#24 0x00405bc6 in TclEvalObjvInternal ()
#25 0x0042375e in TclExecuteByteCode ()
#26 0x00422ad3 in TclCompEvalObj ()
#27 0x0042d0e1 in TclObjInterpProc ()
#28 0x00405bc6 in TclEvalObjvInternal ()
#29 0x0042375e in TclExecuteByteCode ()
#30 0x00422ad3 in TclCompEvalObj ()
#31 0x004069fa in Tcl_EvalObjEx ()
#32 0x004390c6 in NamespaceEvalCmd ()
#33 0x00438974 in Tcl_NamespaceObjCmd ()
#34 0x00405bc6 in TclEvalObjvInternal ()
#35 0x00406533 in Tcl_EvalEx ()
#36 0x004068cc in Tcl_Eval ()
#37 0x00482c9c in Itcl_Init ()
#38 0x0041eecb in Tcl_LoadObjCmd ()
#39 0x00405bc6 in TclEvalObjvInternal ()
#40 0x00406533 in Tcl_EvalEx ()
#41 0x0047cc3c in ThreadSendEval ()
#42 0x0047e073 in ThreadEventProc ()
#43 0x00458056 in Tcl_ServiceEvent ()
#44 0x004582fd in Tcl_DoOneEvent ()
#45 0x0047dcf0 in ThreadWait ()
#46 0x0047c69c in ThreadWaitObjCmd ()
#47 0x00405bc6 in TclEvalObjvInternal ()
#48 0x00406533 in Tcl_EvalEx ()
#49 0x004068cc in Tcl_Eval ()
#50 0x0047d052 in NewThread@4 ()
#51 0x7800248d in _libuser32_a_iname ()
#52 0x77e837cd in _libuser32_a_iname ()
When replaced Tcl_Close() in Tcl_FSEvalFile(), Tcl
panics about Tcl_FindHashEntry on deleted table. It
seems that refCount is messed somehow.
BT:
#1 0x0041fcb3 in BogusFind ()
#2 0x0043854a in Tcl_FindNamespaceVar ()
#3 0x00408525 in TclLookupSimpleVar ()
#4 0x00407ef9 in TclLookupVar ()
#5 0x00408b9f in Tcl_SetVar2Ex ()
#6 0x00408b37 in Tcl_SetVar2 ()
#7 0x004131fe in Tcl_SetErrorCodeVA ()
#8 0x00413235 in Tcl_SetErrorCode ()
#9 0x00405920 in TclInterpReady ()
#10 0x00405d43 in Tcl_EvalObjv ()
#11 0x004069a4 in Tcl_EvalObjEx ()
#12 0x004016cd in rcOutput ()
#13 0x00414708 in CloseChannel ()
#14 0x00414610 in FlushChannel ()
#15 0x00414aad in Tcl_Close ()
#16 0x004133cd in TclFinalizeIOSubsystem ()
#17 0x00410b82 in Tcl_FinalizeThread ()
#18 0x00410a61 in Tcl_Finalize ()
#19 0x00410823 in Tcl_Exit ()
#20 0x004dca8c in Tk_MainEx ()
#21 0x004022ae in WinMain@16 ()
#22 0x0057b131 in main ()
| ||||
| User Comments: | ||||
zoro2 added on 2002-11-10 18:39:05:
Logged In: YES
user_id=191529
Here's a quick fix which seems to work fine for loading Itcl
on windows. It is ugly and the problem does return in other
places as well :-(. I'll try and find the source of the problem.
--- tclO/generic/tclIOUtil.c 2002-08-16
16:37:50.000000000 +0200
+++ tcl/generic/tclIOUtil.c 2002-11-10 12:35:12.000000000 +0100
@@ -29,6 +29,7 @@
/* for tclWinProcs->useWide */
#include "tclWinInt.h"
#endif
+#include "tclIO.h"
/*
* Prototypes for procedures defined later in this file.
@@ -1339,6 +1340,7 @@
goto end;
}
chan = Tcl_FSOpenFileChannel(interp, pathPtr, "r", 0644);
+ ((Channel *) chan)->state->refCount=0;
if (chan == (Tcl_Channel) NULL) {
Tcl_ResetResult(interp);
Tcl_AppendResult(interp, "couldn't read file \"",
zoro2 added on 2002-11-11 05:41:58:
Logged In: YES
user_id=191529
I digged a bit more and found out that this problem occured
with the vfs package - which is used in TclKit to load
itcl.tcl and other modules.
The problem is weird, and probably not vfs module related,
since it only happens in Tcl_FSEvalFile and only on Windows
- using Tcl's open/read/close does not cause any errors at
all. It probably sets refCount wrong somewhere in either vfs
or Tcl module.
A good workaround is to rewrite source to use
open/read/close for each thread:
proc ::source {file} {
if {[catch {set fh [open $file r]; set body [read $fh];
close $fh} rc]} {
return -code error -errorinfo $rc -errorcode
$::errorCode $rc
}
set s [info script]
info script $file
if {[catch {uplevel 1 $body} rc]==1} {
info script $s
catch {thread::send -async $threadpool::mainthread
[list puts $::errorInfo]}
return -code error -errorinfo $rc -errorcode
$::errorCode $rc
}
info script $s
return $rc
}
This code slows things down a bit, but it does not require
any patches to the core and may prove useful until a real
solution is found.
vincentdarley added on 2002-11-11 20:00:37:
Logged In: YES user_id=32170 This appears to be an IO system problem, not a file system problem. hobbs added on 2003-05-11 07:18:20:
Logged In: YES user_id=72656 FWIW, I have also found the need to overload source with the open/read/close/eval alternative - but only in tclkits (works fine in regular shells). I suspect that there is some VFS or tclkit issue lingering there. | ||||
