Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2003-01-29
21:05 • Ticket [674514ffff] Is Tcllib thread safe? - code analysis, flaw detection s... artifact: 3254760a0c user: elfring
2003-01-28
00:18 • Ticket [674514ffff]: 7 changes artifact: a8dd1e5e08 user: elfring
2003-01-27
22:19 • Closed ticket [674514ffff]. artifact: 84655928a7 user: dkf
21:20 • Ticket [674514ffff]: 4 changes artifact: 743d7e3365 user: vasiljevic
19:44 • Ticket [674514ffff]: 5 changes artifact: 6908973787 user: elfring
2003-01-26
20:29 • Open ticket [674514ffff]. artifact: 7a20c43f1b user: elfring
03:23 • Closed ticket [674514ffff]. artifact: 475261cc32 user: hobbs
2003-01-25
16:48 • Ticket [674514ffff]: 4 changes artifact: 50c34aa3a6 user: vasiljevic
09:30 • New ticket [674514ffff]. artifact: e5e0461ded user: elfring

Is Tcllib thread safe? - code analysis, flaw detection

Closed / Accepted674514ffffffffffffffffffffffffffffffffffCreated 24 years agoUpdated 24 years ago
Descriptionplain2003-01-25 09:30:41
Do you know which functions of the Tcl Standard Library can be used 
safely (no extra synchronization needed) with Tcl threads?
When 
will the information be added to the documentation 
(http://tcllib.sourceforge.net/doc/index.html)whether a function in 
this application programming interface is thread-safe or 
asynchronous-safe or not?
vasiljevicplain2003-01-25 16:48:16
Logged In: YES 
user_id=95086

Generally speaking, all Tcl code should be thread-safe. 
It is the C-code which makes (might make) problems. 
Also very important to note is the Tcl "cd" command, which 
although thread-safe per-se, changes the process current 
directory for every thread in the process and is, thus, source 
of potential problems.
hobbsplain2003-01-26 03:23:21
Logged In: YES 
user_id=72656

All pure Tcl code is thread-safe due to the nature of the core.
elfringplain2003-01-26 20:29:15
Logged In: YES 
user_id=572001

1. Is the library "Tcllib" written in "pure Tcl code"?

2. Please add your 
answers to the documentation.
   I would like to see there a general 
statement about reentrant, thread-safe and asynchronous-safe 
functions.
- http://www.gnu.org/software/pth/pth-manual.html#the 
world of threading
- 
http://www.tru64unix.compaq.com/docs/base_doc/DOCUMENTATION/V51_HTML/ARH9RBTE/DOCU0008.HTM#nonthreaded
elfringplain2003-01-27 19:44:43
Logged In: YES 
user_id=572001

1. Is there a source file that might be not thread-safe and not 
asynchronous-safe because it was written in a programming 
language like C oder C++?

3. Are the source files that are not written in TCL checked with 
tools like the following?
- http://splint.org/
- http://www.garret.ru/~knizhnik/jlint/ReadMe.htm#introduction
- http://www.cs.utexas.edu/users/emery/#broadway
vasiljevicplain2003-01-27 21:20:41
Logged In: YES 
user_id=95086

I do not understand... 
 
The thread-extension itself is thread-safe. 
All Tcl code is already thread-safe because of the  
thread-safe Tcl core. 
Arbitrary exensions loaded into the Tcl shell are out 
of the scope of my work. Normally, the package author 
should make his/her code thread-safe if you want to use 
his/her code in the MT-enabled Tcl shell.  
 
I normally run the Purify checker on all of my C-code. 
I do not exercise the code wth any other MT-tool. 
I never had any need for that, yet :-)
dkfplain2003-01-27 22:19:58
Logged In: YES 
user_id=79902

Markus: Tcllib does not contain any non-Tcl source files, by
explicit policy (though not for thread-safety but rather
app-developer accessibility reasons.)  Consequently, they
are guaranteed to be at least as thread-safe as the Tcl core
itself.  However, there are some operations that are part of
the core which are best not used from a multi-threaded
context, though the only one I can think of right now is
[cd] (because it affects a per-process resource.)  However,
it is quite possible (and in-fact easy, especially with the
right options to [glob] etc.) to write Tcl scripts that
never rely on the current directory after a start-up period,
and it is poor policy indeed to write a library which
depends on the current directory!  Ultimately, it is best to
keep the current directory as a user-concept, coupling each
[cd] to a request to change the current directory by the
user.

Closing this FRQ since it is categorically satisfied to the
extent that the Tcl project at SF is interested in it. 
Further questions should be raised with the tcllib project
itself, or in the tcl-threads mailing list.
elfringplain2003-01-28 00:18:27
Logged In: YES 
user_id=572001

Thank you for your answers.
It was that kind of information that I was looking for.

I hope that all Tcllib users know about these thread-safety issues 
with Tcl code.
elfringplain2003-01-29 21:05:09
Logged In: YES 
user_id=572001

Thank you for your answers.
It was that kind of information that I was looking for.

I hope that all Tcllib users know about these thread-safety issues 
with Tcl code.
Log in (anonymous is fine) to add a comment.