Hi! After I have observed some very subtle and hard-to-reproduce bugs in our app, I found out that Tcl object handling in some places in NS code, although "by the book" is really a source of trouble. Like:
Tcl_SetIntObj(Tcl_GetObjResult(interp), 1); /* Unsafe? */ This construct assumes that object stored in the interp result is not shared. I do not know, and I will have to make the journey on Tcl core list, if it is possible to have a shared object in the interp result or not, but it seems to me that it is. OR, there is some other source or problem which I do not know. But, when I modify it to look like: Tcl_SetObjResult(interp, Tcl_NewIntObj(1)); /* Safe! */ then all works fine. This is not only the case with the Int but with all other object types as well. Difference between the two is that the first one saves creation of a new Tcl object, as it re-uses the one stored in the interp result. But, creation of Tcl object is relatively cheap operation (pop from the list) so there is not really much that it's saved. I have gone thru the sources and replaced all those "problematic" spots and would kindly ask any C-code commiter to pay attention to the above. Until we explicitly find out what is happening and why, I'd consider the above construct "unsafe" and would refrain from using it. Thanks Zoran