#1951 Tcl_FSCreateDirectory() aborts

obsolete: 8.4b1

Tcl_FSCreateDirectory() aborts with:

UpdateStringProc should not be invoked for type path
Aborted (core dumped)

when the argument object has a refcount of 0, e.g.

Tcl_FSCreateDirectory(Tcl_NewStringObj("foo", -1));

The backtrace looks like this:

#0 0x400f7ab1 in kill () from /lib/libc.so.6
#1 0x400f78a8 in raise () from /lib/libc.so.6
#2 0x400f8edb in abort () from /lib/libc.so.6
#3 0x40091ade in Tcl_PanicVA () from /usr/lib/libtcl8.4.so
#4 0x40091b06 in Tcl_Panic () from /usr/lib/libtcl8.4.so
#5 0x4008fec6 in Tcl_GetStringFromObj () from
#6 0x40085cbd in Tcl_FSJoinPath () from
#7 0x4008579d in Tcl_FSGetPathType () from
#8 0x40085721 in Tcl_FSGetPathType () from
#9 0x40086dab in Tcl_FSGetNormalizedPath () from
#10 0x40087290 in Tcl_FSGetFileSystemForPath () from
#11 0x40086152 in Tcl_FSCreateDirectory () from


  • Vince Darley

    Vince Darley - 2002-07-08

    Logged In: YES

    This obviously isn't ideal, but calling Tcl_FSAnything in
    that way is clearly going to leak memory even if the
    result succeeds. The docs explicitly say that you
    should not call these APIs with refCounts of zero:

    "The \fBTcl_FS...\fR are objectified and may cache
    representations and other path-related strings (e.g. the
    working directory). One side-effect of this is that one
    must be
    careful when passing in temporary objects with a
    refCount of zero.
    Under some circumstances, the filesystem code may
    wish to retain a
    reference to the passed in object, and so one must not
    assume that
    after any of these calls return, the object still has a
    refCount of
    zero - it may have been incremented. The practical
    lesson to learn
    from this is that \fBTcl_Obj *path = Tcl_NewStringObj
    (...) ;
    Tcl_FS...(path) ; Tcl_DecrRefCount(path)\fR is wrong,
    and may
    segfault. The 'path' must have its refCount incremented
    passing it in, or decrementing it."

    I'll try to fix the crash in any case...

  • Reinhard Max

    Reinhard Max - 2002-07-08

    Logged In: YES

    Oops, sorry. I had overlooked that part of the manpage.

  • Vince Darley

    Vince Darley - 2002-07-08

    Logged In: YES

    Removed crash, but such a zero-refcount function call
    will simply return an error. Clarified docs.

  • Vince Darley

    Vince Darley - 2002-07-08
    • status: open --> closed-fixed

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

Sign up for the SourceForge newsletter:

No, thanks