Tcl Source Code

View Ticket
Login
Ticket UUID: 711232
Title: Darwin realpath() and threads problem
Type: Bug Version: obsolete: 8.4.2
Submitter: vasiljevic Created on: 2003-03-28 08:42:15
Subsystem: 36. Pathname Management Assigned To: das
Priority: 9 Immediate Severity:
Status: Closed Last Modified: 2003-05-13 15:48:13
Resolution: Fixed Closed By: das
    Closed on: 2003-05-13 08:48:11
Description:
The Tcl8.4.x uses the OS-call realpath() to figure-out the
real physical path of the file on the filesystem, stripped 
of all "./", "../", constructs, symlinks and alike. 

This function on Darwin uses chdir/fchdir internally
which changes the process current working directory
for each invocation. It is called for just about
*every* path you pass to the Tcl library! Of course, 
this defeats *any* multithreading code. There is no
single point like [cd] command which mingles with the
current dir; *all* path arithmetics eventually call into
the realpath() and it will swap the current dir under
your feet. The man page says nothing about this
important side-effect, though. This is not the case in 
Solaris and/or Linux OS. It appears to me that it only
happens on Mac OSX (aka Darwin). 

First corrective measure is to define NO_REALPATH
variable on compilation time. Of course, in one of my 
previous threads.
Better yet is to fix Darwin realpath() to behave better.
User Comments: das added on 2003-05-13 15:48:13:

File Added - 50236: tclUnixPort.diff

das added on 2003-05-13 15:48:11:
Logged In: YES 
user_id=90580

commited the workaround suggested above to core-8-4-branch 
and HEAD: define NO_REALPATH  for threaded build on Mac 
OS X, c.f. attached patch.

A better fix would be to add a thread-safe realpath 
implementation to tcl/compat and use this instead of the realpath 
in libc.

Attachments: