#2575 workaround for buggy(??) mkstemp() on IRIX systems

obsolete: 8.4.5

This bug concerns only IRIX systems (6.5.19m) so far.

Using a tclkit with included dynamic libraries results
in the following
error message when loading a second dynamic library
from the vfs:

> tclkit-irix
% package require Itcl
% package require Tk
couldn't find procedure Tk_Init

I tracked it down to the temporary filename create
mkstemp() in
TclpTempFileName() in tclUnixPipe.c. mkstemp() always
uses the
same filename, but keeps the content of the first file
copied into
it. I.e. a second call of TclCrossFilesystemCopy()
means that the
content of the first call is still present causing
TclpFindSymbol() not
to find the <EXT>_Init() procedure.
Adding a counter to the temporary filename solves this
problem. I
submit a patch as well.

hope that helps


ps: i just wonder whether i am the first one, using
tclkits under IRIX.


  • Gerd Sussner

    Gerd Sussner - 2004-01-16

    patch to fix problem with temp. filenames on IRIX

  • Vince Darley

    Vince Darley - 2004-01-17
    • assigned_to: vincentdarley --> dgp
  • Vince Darley

    Vince Darley - 2004-01-17

    Logged In: YES

    Assigned to someone who knows more about Unix ;-)

  • Donal K. Fellows

    • assigned_to: dgp --> dkf
  • Donal K. Fellows

    Logged In: YES

    Assigning to myself because I've got access to IRIX systems

  • Joe English

    Joe English - 2004-02-20

    Logged In: YES

    This looks more like a bug in TclpTempFileName() -- it calls
    mkstemp() to generate a temporary file, but then deletes the
    file and closes the file descriptor. So a subsequent call
    to mkstemp() can use the same filename, as it's still unique.

    As a matter of fact, TclpTempFileName() is Broken As
    Designed: there is no safe way to generate a temporary file
    name without creating the file at the same time; otherwise
    you suffer a race condition.

  • Joe English

    Joe English - 2004-02-20
    • assigned_to: dkf --> vincentdarley
  • Joe English

    Joe English - 2004-02-20

    Logged In: YES

    It looks like Tcl_FSLoadFile() is the only caller of
    TclpTempFileName() in the core. This should be fixed, and
    TclpTempFileName() removed. Back to you, Vince!

  • Vince Darley

    Vince Darley - 2004-02-23
    • assigned_to: vincentdarley --> jenglish
  • Vince Darley

    Vince Darley - 2004-02-23

    Logged In: YES

    It looks as if Tcl_FSLoadFile doesn't mind if the return
    value of TclpTempFileName exists or not, so perhaps that
    function can be changed not to delete the file? Or it
    should be changed to ensure it always creates a new empty
    name with an empty file?

    I don't quite understand what Joe is suggesting... How can
    we get rid of TclpTempFileName()? It's needed by
    Tcl_FSLoadFile... I can understand that we might want to
    fix TclpTempFileName() and/or adjust how it is called, what
    it returns, but _remove_ it !?!?

  • Donal K. Fellows

    Logged In: YES

    AIUI, what we need to do is to get the temporary file name
    back and at the same time have the temporary file open for
    modification (keeping it open stops some security-related
    race conditions).

    BTW, I think I do not agree with removing TclpTempFileName()
    (though altering its API sounds like a good thing) since it
    might well end up being useful elsewhere in the core in the
    future (e.g. for loading Win icons and cursors from starkits.)

  • Joe English

    Joe English - 2004-02-23

    Logged In: YES

    Changing the API to return an open channel handle as well as
    the filename would also work (just that it's usually good
    practice to change the name of a function when you change
    its semantics).

    But TclpTempFileName() as currently specified cannot be
    implemented correctly and cannot be used safely.

  • Don Porter

    Don Porter - 2006-03-10

    Logged In: YES


  • Joe English

    Joe English - 2006-03-10

    Logged In: YES

    Still not fixed. The TIP#210 implementation will provide
    what's needed to solve the problem.

  • Rene

    Rene - 2007-03-05

    Logged In: YES
    Originator: NO

    I had the same problems in creating and using tclkits under IRIX.
    To avoid this I had to manually patch the tcl sources.

    Why not add the patch for IRIX?


  • Donal K. Fellows

    • priority: 5 --> 7
  • Donal K. Fellows

    • priority: 7 --> 8
    • assigned_to: jenglish --> dkf
    • status: open --> open-remind
  • Donal K. Fellows

    Now that we have compat/mkstemp.c, fix is trivial. Done for 8.6 release.

  • Donal K. Fellows

    • status: open-remind --> closed-fixed

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks